Enum cargo_platform::Platform
source · pub enum Platform {
Name(String),
Cfg(CfgExpr),
}
Expand description
Platform definition.
Variants§
Name(String)
A named platform, like x86_64-apple-darwin
.
Cfg(CfgExpr)
A cfg expression, like cfg(windows)
.
Implementations§
source§impl Platform
impl Platform
sourcepub fn matches(&self, name: &str, cfg: &[Cfg]) -> bool
pub fn matches(&self, name: &str, cfg: &[Cfg]) -> bool
Returns whether the Platform matches the given target and cfg.
The named target and cfg values should be obtained from rustc
.
Examples found in repository?
examples/matches.rs (line 29)
18 19 20 21 22 23 24 25 26 27 28 29 30 31
fn main() {
let target = get_target();
let cfgs = get_cfgs();
println!("host target={} cfgs:", target);
for cfg in &cfgs {
println!(" {}", cfg);
}
let mut examples: Vec<&str> = EXAMPLES.iter().copied().collect();
examples.push(target.as_str());
for example in examples {
let p = Platform::from_str(example).unwrap();
println!("{:?} matches: {:?}", example, p.matches(&target, &cfgs));
}
}
pub fn check_cfg_attributes(&self, warnings: &mut Vec<String>)
Trait Implementations§
source§impl<'de> Deserialize<'de> for Platform
impl<'de> Deserialize<'de> for Platform
source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Ord for Platform
impl Ord for Platform
source§impl PartialEq for Platform
impl PartialEq for Platform
source§impl PartialOrd for Platform
impl PartialOrd for Platform
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Eq for Platform
impl StructuralPartialEq for Platform
Auto Trait Implementations§
impl Freeze for Platform
impl RefUnwindSafe for Platform
impl Send for Platform
impl Sync for Platform
impl Unpin for Platform
impl UnwindSafe for Platform
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