Skip to content

Commit

Permalink
Avoid PackageType in doctests
Browse files Browse the repository at this point in the history
`PackageType` is only available with the `package-type` feature. So it's
best to avoid it in unrelated doctests. Otherwise, they will fail when
run without default features.
  • Loading branch information
kylewillmon committed Oct 31, 2023
1 parent 878004b commit 616e019
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
5 changes: 2 additions & 3 deletions purl/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ use crate::{GenericPurl, ParseError, PurlParts, PurlShape, SmallString};
/// # Example
///
/// ```
/// // `PurlBuilder` is an alias for `GenericPurlBuilder<PackageType>`.
/// use purl::{PackageType, PurlBuilder};
/// use purl::GenericPurlBuilder;
///
/// // Use the builder if you want to set fields besides the type and name.
/// let purl = PurlBuilder::new(PackageType::Maven, "my-package")
/// let purl = GenericPurlBuilder::new(String::from("maven"), "my-package")
/// .with_namespace("my.company")
/// .build()
/// .unwrap();
Expand Down
8 changes: 5 additions & 3 deletions purl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,13 @@ pub struct PurlParts {
/// # Example
///
/// ```
/// // `Purl` is an alias for `GenericPurl<PackageType>`.
/// use purl::{PackageType, Purl};
/// use purl::GenericPurl;
///
/// // Use the builder if you want to set fields besides the type and name.
/// let purl = Purl::builder(PackageType::Npm, "my-package").with_version("1.2.3").build().unwrap();
/// let purl = GenericPurl::builder(String::from("npm"), "my-package")
/// .with_version("1.2.3")
/// .build()
/// .unwrap();
///
/// assert_eq!("pkg:npm/[email protected]", &purl.to_string());
/// ```
Expand Down

0 comments on commit 616e019

Please sign in to comment.