pub struct Dependency {
pub kind: DependencyKind,
pub from: PackageID,
pub on: PackageID,
/* private fields */
}Expand description
A relation of dependency between 2 crate::Packages
Fields§
§kind: DependencyKindType of dependency
from: PackageIDID of the package that defined this dependency
on: PackageIDID of the package that is being depended on
Implementations§
Source§impl Dependency
impl Dependency
Sourcepub fn svs(&self) -> Option<&SourceVersionSpecifier>
pub fn svs(&self) -> Option<&SourceVersionSpecifier>
The source and version range chosen by the dependent package.
§Example
let svs = dependency.svs().unwrap();
assert_eq!(svs, "^4.2.0");
assert!(svs.is_npm());Sourcepub fn alias_name<'a>(&'a self) -> Option<PackageNameBorrowed<'a>>
pub fn alias_name<'a>(&'a self) -> Option<PackageNameBorrowed<'a>>
If the dependency is from npm, aliasing a package with a different name,
this represents the name under which it’s aliased, e.g. if package.json defines
the dependency as "lodash": "npm:@chastelock/lodash-fork@^4.0.0",
crate::Package::name will be @chastelock/lodash-fork, but crate::Dependency::alias_name
will be lodash. (If dependency is not from npm, the behavior is undefined.)
§Example
let dependencies = chastefile.package_dependencies(root_pid);
let dependency = dependencies.first().unwrap();
assert_eq!(chastefile.package(dependency.on).name().unwrap(), "@chastelock/lodash-fork");
assert_eq!(dependency.alias_name().unwrap(), "lodash");Trait Implementations§
Source§impl Clone for Dependency
impl Clone for Dependency
Source§fn clone(&self) -> Dependency
fn clone(&self) -> Dependency
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for Dependency
impl RefUnwindSafe for Dependency
impl Send for Dependency
impl Sync for Dependency
impl Unpin for Dependency
impl UnwindSafe for Dependency
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
Mutably borrows from an owned value. Read more