pub enum Target<String = String> {
Triple {
arch: String,
vendor: String,
os: String,
env: Option<String>,
},
Cfg(Cfg<String>),
}
Variants§
Implementations§
source§impl<String: AsRef<str>> Target<String>
impl<String: AsRef<str>> Target<String>
sourcepub fn eval<'cfg, GetterCallback>(&'cfg self, getter: GetterCallback) -> boolwhere
GetterCallback: Fn(&'cfg str, &'cfg str) -> Option<&'cfg str>,
pub fn eval<'cfg, GetterCallback>(&'cfg self, getter: GetterCallback) -> boolwhere GetterCallback: Fn(&'cfg str, &'cfg str) -> Option<&'cfg str>,
Check if the target matches keys returned by the getter.
The getter takes a key, and a hint of the value that it’s being compared against (to handle feature = "value"
).
Value given to the callback will be ""
for existence checks (like cfg(unix)
).
The callback returns Some
with the key’s actual value if it’s set, or None
if the key is not set. For booleans equal true return Some("")
.
NB: don’t use move
closures for the callback, because these aren’t allowed to return data they own. Use closures temporarily borrowing the data from their outer scope.
Targets check for target_arch, target_vendor, target_os, and target_env separately.
See rustc --print=cfg
for list of values to set to emulate proper environment, and rustup target list
for list of valid target triples.
source§impl Target<String>
impl Target<String>
sourcepub fn parse(target_triple_or_cfg: &str) -> Result<Self, ParseError>
pub fn parse(target_triple_or_cfg: &str) -> Result<Self, ParseError>
Parse a target triple or a cfg(…)
expression.
Supports values that are valid in Cargo’s [target.<this expression>.dependencies]
.
Parses into owned String
s.
source§impl<'input> Target<&'input str>
impl<'input> Target<&'input str>
sourcepub fn parse_ref(target_triple_or_cfg: &'input str) -> Result<Self, ParseError>
pub fn parse_ref(target_triple_or_cfg: &'input str) -> Result<Self, ParseError>
Parse a target triple or a cfg(…)
expression.
Supports values that are valid in Cargo’s [target.<this expression>.dependencies]
.
Parses into temporarily borrowed &str
s.
source§impl<'input, String: From<&'input str>> Target<String>
impl<'input, String: From<&'input str>> Target<String>
sourcepub fn parse_generic(
target_triple_or_cfg: &'input str
) -> Result<Self, ParseError>
pub fn parse_generic( target_triple_or_cfg: &'input str ) -> Result<Self, ParseError>
Parse a target triple or a cfg(…)
expression.
Supports values that are valid in Cargo’s [target.<this expression>.dependencies]
.
Parses into any string-like type