pub struct PackageName(/* private fields */);Expand description
A package name: one flat identifier, ASCII lowercase letters, digits and hyphens,
starting with a letter, with every hyphen followed by a letter —
docs/spec/packages.md’s whole rule for
name. That shape is what keeps a package name and a module name from ever being
confused (one is lowercase-with-hyphens, the other uppercase-with-dots), and what makes
the namespace a package’s name derives unambiguous.
The only way to build one is PackageName::new, which rejects anything that does not
match the rule — there is no way to hold a PackageName that manifest validation would
have refused.
Implementations§
Source§impl PackageName
impl PackageName
Sourcepub fn new<S: Into<String>>(name: S) -> Result<PackageName, InvalidPackageName>
pub fn new<S: Into<String>>(name: S) -> Result<PackageName, InvalidPackageName>
Build a PackageName, or say why name is not one.
pub fn as_str(&self) -> &str
Sourcepub fn core() -> PackageName
pub fn core() -> PackageName
zelkova-core, resolve::CORE_PACKAGE: the one package the compiler names
on its own, because it is where the scalars are declared.
Built without going through PackageName::new’s check, so that naming a scalar
needs no unwrap; that the constant passes the check is a unit test.
Sourcepub fn is_core(&self) -> bool
pub fn is_core(&self) -> bool
Whether this is zelkova-core, the one package the default imports and the
scalar seeding they are replaced by both key themselves on
(DEC-17 decision 4) — and, since
resolve::visible_modules rejects any other package that declares one of
the eight, the only package that can be shaped like it.
Sourcepub fn namespace(&self) -> Name
pub fn namespace(&self) -> Name
The prefix this package’s modules are named through from outside it: the name
split at its hyphens, each piece capitalised, joined —
The namespace. acme-widgets is
AcmeWidgets, todo is Todo.
It is a Name and not a PackageName: what comes back is a module-name
prefix, and the whole point of the shape rule above is that the two are never
confusable. Distinct package names give distinct namespaces, which is what lets
two wrapped dependencies keep out of each other’s way with nothing checked.
A package never writes its own namespace, so nothing inside the package being
compiled goes through here: resolve::visible_modules is the one caller, and
it applies this only to a dependency’s modules.
Trait Implementations§
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 Hash for PackageName
impl Hash for PackageName
Source§impl PartialEq for PackageName
impl PartialEq 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
key and return true if they are equal.