pub struct Workspace<'g> { /* private fields */ }
Expand description
Information about a workspace, parsed from metadata returned by cargo metadata
.
For more about workspaces, see Cargo Workspaces in The Rust Programming Language.
Implementations
sourceimpl<'g> Workspace<'g>
impl<'g> Workspace<'g>
These parallel iterators require the rayon1
feature is enabled.
sourcepub fn par_iter(&self) -> impl ParallelIterator<Item = PackageMetadata<'g>>
This is supported on crate feature rayon1
only.
pub fn par_iter(&self) -> impl ParallelIterator<Item = PackageMetadata<'g>>
rayon1
only.Returns a parallel iterator over package metadatas, sorted by workspace path.
Requires the rayon1
feature to be enabled.
sourcepub fn par_iter_by_path(
&self
) -> impl ParallelIterator<Item = (&'g Utf8Path, PackageMetadata<'g>)>
This is supported on crate feature rayon1
only.
pub fn par_iter_by_path(
&self
) -> impl ParallelIterator<Item = (&'g Utf8Path, PackageMetadata<'g>)>
rayon1
only.Returns a parallel iterator over workspace paths and package metadatas, sorted by workspace paths.
Requires the rayon1
feature to be enabled.
sourcepub fn par_iter_by_name(
&self
) -> impl ParallelIterator<Item = (&'g str, PackageMetadata<'g>)>
This is supported on crate feature rayon1
only.
pub fn par_iter_by_name(
&self
) -> impl ParallelIterator<Item = (&'g str, PackageMetadata<'g>)>
rayon1
only.Returns a parallel iterator over workspace names and package metadatas, sorted by package names.
Requires the rayon1
feature to be enabled.
sourceimpl<'g> Workspace<'g>
impl<'g> Workspace<'g>
sourcepub fn member_count(&self) -> usize
pub fn member_count(&self) -> usize
Returns the number of packages in this workspace.
sourcepub fn contains_name(&self, name: impl AsRef<str>) -> bool
pub fn contains_name(&self, name: impl AsRef<str>) -> bool
Returns true if the workspace contains a package by the given name.
sourcepub fn contains_path(&self, path: impl AsRef<Utf8Path>) -> bool
pub fn contains_path(&self, path: impl AsRef<Utf8Path>) -> bool
Returns true if the workspace contains a package by the given workspace path.
sourcepub fn iter(
&self
) -> impl Iterator<Item = PackageMetadata<'g>> + ExactSizeIterator
pub fn iter(
&self
) -> impl Iterator<Item = PackageMetadata<'g>> + ExactSizeIterator
Returns an iterator over package metadatas, sorted by the path they’re in.
sourcepub fn iter_by_path(
&self
) -> impl Iterator<Item = (&'g Utf8Path, PackageMetadata<'g>)> + ExactSizeIterator
pub fn iter_by_path(
&self
) -> impl Iterator<Item = (&'g Utf8Path, PackageMetadata<'g>)> + ExactSizeIterator
Returns an iterator over workspace paths and package metadatas, sorted by the path they’re in.
sourcepub fn iter_by_name(
&self
) -> impl Iterator<Item = (&'g str, PackageMetadata<'g>)> + ExactSizeIterator
pub fn iter_by_name(
&self
) -> impl Iterator<Item = (&'g str, PackageMetadata<'g>)> + ExactSizeIterator
Returns an iterator over workspace names and package metadatas, sorted by names.
sourcepub fn member_ids(
&self
) -> impl Iterator<Item = &'g PackageId> + ExactSizeIterator
pub fn member_ids(
&self
) -> impl Iterator<Item = &'g PackageId> + ExactSizeIterator
Returns an iterator over package IDs for workspace members. The package IDs will be returned
in the same order as members
, sorted by the path they’re in.
sourcepub fn member_by_path(
&self,
path: impl AsRef<Utf8Path>
) -> Result<PackageMetadata<'g>, Error>
pub fn member_by_path(
&self,
path: impl AsRef<Utf8Path>
) -> Result<PackageMetadata<'g>, Error>
Maps the given path to the corresponding workspace member.
Returns an error if the path didn’t match any workspace members.
sourcepub fn members_by_paths<B>(
&self,
paths: impl IntoIterator<Item = impl AsRef<Utf8Path>>
) -> Result<B, Error> where
B: FromIterator<PackageMetadata<'g>>,
pub fn members_by_paths<B>(
&self,
paths: impl IntoIterator<Item = impl AsRef<Utf8Path>>
) -> Result<B, Error> where
B: FromIterator<PackageMetadata<'g>>,
Maps the given paths to their corresponding workspace members, returning a new value of
the specified collection type (e.g. Vec
).
Returns an error if any of the paths were unknown.
sourcepub fn member_by_name(
&self,
name: impl AsRef<str>
) -> Result<PackageMetadata<'g>, Error>
pub fn member_by_name(
&self,
name: impl AsRef<str>
) -> Result<PackageMetadata<'g>, Error>
Maps the given name to the corresponding workspace member.
Returns an error if the name didn’t match any workspace members.
sourcepub fn members_by_names<B>(
&self,
names: impl IntoIterator<Item = impl AsRef<str>>
) -> Result<B, Error> where
B: FromIterator<PackageMetadata<'g>>,
pub fn members_by_names<B>(
&self,
names: impl IntoIterator<Item = impl AsRef<str>>
) -> Result<B, Error> where
B: FromIterator<PackageMetadata<'g>>,
Maps the given names to their corresponding workspace members, returning a new value of
the specified collection type (e.g. Vec
).
Returns an error if any of the paths were unknown.
sourceimpl<'g> Workspace<'g>
impl<'g> Workspace<'g>
Helpers for property testing
The methods in this section allow a Workspace
to be used in property-based testing
scenarios.
Currently, proptest 1 is supported if the proptest1
feature is enabled.
sourcepub fn prop010_name_strategy(&self) -> impl Strategy<Value = &'g str> + 'g
This is supported on crate feature proptest1
only.
pub fn prop010_name_strategy(&self) -> impl Strategy<Value = &'g str> + 'g
proptest1
only.Returns a Strategy
that generates random package names from this workspace.
Requires the proptest1
feature to be enabled.
Panics
Panics if there are no packages in this Workspace
.
sourcepub fn prop010_id_strategy(&self) -> impl Strategy<Value = &'g PackageId> + 'g
This is supported on crate feature proptest1
only.
pub fn prop010_id_strategy(&self) -> impl Strategy<Value = &'g PackageId> + 'g
proptest1
only.Returns a Strategy
that generates random package IDs from this workspace.
Requires the proptest1
feature to be enabled.
Panics
Panics if there are no packages in this Workspace
.
Trait Implementations
Auto Trait Implementations
impl<'g> RefUnwindSafe for Workspace<'g>
impl<'g> Send for Workspace<'g>
impl<'g> Sync for Workspace<'g>
impl<'g> Unpin for Workspace<'g>
impl<'g> UnwindSafe for Workspace<'g>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more