pub struct PackageName(/* private fields */);Expand description
A package/crate name as it appears in a manifest file.
This is deliberately permissive: it stores whatever bytes the manifest contained, including the empty string, leading/trailing whitespace, or non-ASCII characters. No validation, trimming, or normalization is performed by this type.
For several ecosystems this is not a “package name” in the narrow sense
but a registry lookup key: Maven and Gradle store "group:artifact", Swift
stores "owner/repo", and Go stores a URL-like module path. All of these
are valid PackageName values. Ecosystem-specific normalization (case
folding, separator rewriting, etc.) is the responsibility of
EcosystemFormatter, not this type — do not add validation rules here,
as it would silently break those ecosystems.
§Examples
use deps_core::PackageName;
let name = PackageName::new("serde");
assert_eq!(name.as_str(), "serde");
assert_eq!(name, "serde");Implementations§
Source§impl PackageName
impl PackageName
Sourcepub fn new(value: impl Into<String>) -> Self
pub fn new(value: impl Into<String>) -> Self
Wraps value as a PackageName, unchanged.
This never fails and never modifies its input: an empty string is a
valid PackageName, as is a string with surrounding whitespace.
§Examples
use deps_core::PackageName;
let name = PackageName::new(String::from("tokio"));
assert_eq!(name.as_str(), "tokio");Sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
Returns the package name as a string slice.
§Examples
use deps_core::PackageName;
let name = PackageName::new("axum");
assert_eq!(name.as_str(), "axum");Sourcepub fn into_string(self) -> String
pub fn into_string(self) -> String
Consumes the PackageName, returning the wrapped String.
§Examples
use deps_core::PackageName;
let name = PackageName::new("axum");
let owned: String = name.into_string();
assert_eq!(owned, "axum");Trait Implementations§
Source§impl AsRef<str> for PackageName
impl AsRef<str> for PackageName
Source§impl Borrow<str> for PackageName
Enables &str lookups into HashMap<PackageName, _>/HashSet<PackageName>.
impl Borrow<str> for PackageName
Enables &str lookups into HashMap<PackageName, _>/HashSet<PackageName>.
Sound because derived Hash/Eq on PackageName(String) delegate to
String’s implementations, which in turn are defined to match str’s
exactly (String: Borrow<str> in std rests on the same guarantee) — so
PackageName and the str it borrows always hash and compare equal.
Source§impl Clone for PackageName
impl Clone for PackageName
Source§fn clone(&self) -> PackageName
fn clone(&self) -> PackageName
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PackageName
impl Debug for PackageName
Source§impl Display for PackageName
impl Display for PackageName
impl Eq for PackageName
Source§impl From<&str> for PackageName
impl From<&str> for PackageName
Source§impl From<String> for PackageName
impl From<String> for PackageName
Source§impl Hash for PackageName
impl Hash for PackageName
Source§impl PartialEq for PackageName
impl PartialEq for PackageName
Source§fn eq(&self, other: &PackageName) -> bool
fn eq(&self, other: &PackageName) -> bool
self and other values to be equal, and is used by ==.Source§impl PartialEq<&str> for PackageName
impl PartialEq<&str> for PackageName
Source§impl PartialEq<str> for PackageName
impl PartialEq<str> for PackageName
impl StructuralPartialEq for PackageName
Auto Trait Implementations§
impl Freeze for PackageName
impl RefUnwindSafe for PackageName
impl Send for PackageName
impl Sync for PackageName
impl Unpin for PackageName
impl UnsafeUnpin for PackageName
impl UnwindSafe for PackageName
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.