expression
Choose an embedded target from the CPU and ABI
A compilation target identifies an instruction-set and ABI combination, not a particular board. Armv6-M uses the soft-float ABI; Armv7E-M has soft-float and hard-float variants. Select hard-float only when the device, runtime initialization and linked objects support it. The model accepts explicitly known device facts; it is not automatic hardware detection. Expected host stdout (not executed): thumbv6m-none-eabi invalid: true Common mistake: Selecting a target solely from the presence of the word ARM.
Formal Syntax & Structure
rust syntaxrust
thumbv6m-none-eabi / thumbv7em-none-eabi / thumbv7em-none-eabihfWorking Example
Example Snippetrust
fn target(v7em: bool, hard_float: bool) -> Option<&'static str> { match (v7em, hard_float) { (false, false) => Some("thumbv6m-none-eabi"), (true, false) => Some("thumbv7em-none-eabi"), (true, true) => Some("thumbv7em-none-eabihf"), _ => None, }}fn main() { println!("{}", target(false, false).unwrap()); println!("invalid: {}", target(false, true).is_none());}