Debian Codegraph @

src/manifest.rs

raw symbols SCIP
1 //! Cargo flag for selecting the relevant crate.
2
3 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/;
4
5 /// Cargo flag for selecting the relevant crate.
6 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:)]
7 #[cfg_attr(feature = "clap", derive(claprust-analyzer cargo clap 4.5.48 crate/::Argsrust-analyzer cargo clap_derive 4.5.47 Args:))]
8 #[cfg_attr(feature = "clap", command(about = None, long_about = None))]
9 #[non_exhaustive]
10 pub struct Manifestrust-analyzer cargo clap-cargo 0.18.3 manifest/Manifest# {
11 #[cfg_attr(feature = "clap", arg(long, name = "PATH"))]
12 /// Path to Cargo.toml
13 pub manifest_pathrust-analyzer cargo clap-cargo 0.18.3 manifest/Manifest#manifest_path.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#>,
14 }
15
16 #[cfg(feature = "cargo_metadata")]
17 impl Manifestrust-analyzer cargo clap-cargo 0.18.3 manifest/Manifest# {
18 /// Create a `cargo_metadata::MetadataCommand`
19 ///
20 /// Note: Requires the features `cargo_metadata`.
21 pub fn metadatarust-analyzer cargo clap-cargo 0.18.3 manifest/impl#[Manifest]metadata().(&self) -> cargo_metadatarust-analyzer cargo cargo_metadata 0.23.0 crate/::MetadataCommandrust-analyzer cargo cargo_metadata 0.23.0 MetadataCommand# {
22 let mut c = cargo_metadatarust-analyzer cargo cargo_metadata 0.23.0 crate/::MetadataCommandrust-analyzer cargo cargo_metadata 0.23.0 MetadataCommand#::newrust-analyzer cargo cargo_metadata 0.23.0 impl#[MetadataCommand]new().();
23 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ref manifest_path) = self.manifest_pathrust-analyzer cargo clap-cargo 0.18.3 manifest/Manifest#manifest_path. {
24 c.manifest_pathrust-analyzer cargo cargo_metadata 0.23.0 impl#[MetadataCommand]manifest_path().(manifest_path);
25 }
26 c
27 }
28 }
29
30 #[cfg(test)]
31 mod testrust-analyzer cargo clap-cargo 0.18.3 manifest/test/ {
32 use superrust-analyzer cargo clap-cargo 0.18.3 manifest/::*;
33
34 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
35 #[cfg(feature = "clap")]
36 fn verify_apprust-analyzer cargo clap-cargo 0.18.3 manifest/test/verify_app().() {
37 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, claprust-analyzer cargo clap 4.5.48 crate/::Parserrust-analyzer cargo clap_derive 4.5.47 Parser:)]
38 struct Clirust-analyzer cargo clap-cargo 0.18.3 manifest/test/Cli# {
39 #[commandrust-analyzer cargo clap_derive 4.5.47 command:(flatten)]
40 manifestrust-analyzer cargo clap-cargo 0.18.3 manifest/test/Cli#manifest.: Manifestrust-analyzer cargo clap-cargo 0.18.3 manifest/Manifest#,
41 }
42
43 use claprust-analyzer cargo clap 4.5.48 crate/::CommandFactoryrust-analyzer cargo clap_builder 4.5.48 derive/CommandFactory#;
44 Clirust-analyzer cargo clap-cargo 0.18.3 manifest/test/Cli#::commandrust-analyzer cargo clap-cargo 0.18.3 manifest/test/impl#[Cli][CommandFactory]command().().debug_assertrust-analyzer cargo clap_builder 4.5.48 builder/command/impl#[Command]debug_assert().();
45 }
46
47 #[cfg(feature = "cargo_metadata")]
48 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
49 fn metadata_with_pathrust-analyzer cargo clap-cargo 0.18.3 manifest/test/metadata_with_path().() {
50 let manifest = Manifestrust-analyzer cargo clap-cargo 0.18.3 manifest/Manifest# {
51 manifest_pathrust-analyzer cargo clap-cargo 0.18.3 manifest/Manifest#manifest_path.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][`From<&T>`]from().("tests/fixtures/simple/Cargo.toml")),
52 };
53 let metadata = manifest.metadatarust-analyzer cargo clap-cargo 0.18.3 manifest/impl#[Manifest]metadata().();
54 metadata.execrust-analyzer cargo cargo_metadata 0.23.0 impl#[MetadataCommand]exec().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
55 // TODO verify we forwarded correctly.
56 }
57
58 #[cfg(feature = "cargo_metadata")]
59 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
60 fn metadata_without_pathrust-analyzer cargo clap-cargo 0.18.3 manifest/test/metadata_without_path().() {
61 let cwd = pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][`From<&T>`]from().("tests/fixtures/simple");
62 let manifest = Manifestrust-analyzer cargo clap-cargo 0.18.3 manifest/Manifest# {
63 manifest_pathrust-analyzer cargo clap-cargo 0.18.3 manifest/Manifest#manifest_path.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
64 };
65 let mut metadata = manifest.metadatarust-analyzer cargo clap-cargo 0.18.3 manifest/impl#[Manifest]metadata().();
66 metadata.current_dirrust-analyzer cargo cargo_metadata 0.23.0 impl#[MetadataCommand]current_dir().(cwd).execrust-analyzer cargo cargo_metadata 0.23.0 impl#[MetadataCommand]exec().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
67 // TODO verify we forwarded correctly.
68 }
69 }