diff options
Diffstat (limited to 'third_party/rust/target-lexicon-0.9.0/examples')
-rw-r--r-- | third_party/rust/target-lexicon-0.9.0/examples/host.rs | 12 | ||||
-rw-r--r-- | third_party/rust/target-lexicon-0.9.0/examples/misc.rs | 14 |
2 files changed, 26 insertions, 0 deletions
diff --git a/third_party/rust/target-lexicon-0.9.0/examples/host.rs b/third_party/rust/target-lexicon-0.9.0/examples/host.rs new file mode 100644 index 0000000000..055e0bffdb --- /dev/null +++ b/third_party/rust/target-lexicon-0.9.0/examples/host.rs @@ -0,0 +1,12 @@ +extern crate target_lexicon; + +use target_lexicon::HOST; + +fn main() { + println!( + "{}", + HOST.pointer_width() + .expect("architecture should be known") + .bytes() + ); +} diff --git a/third_party/rust/target-lexicon-0.9.0/examples/misc.rs b/third_party/rust/target-lexicon-0.9.0/examples/misc.rs new file mode 100644 index 0000000000..25c99e8677 --- /dev/null +++ b/third_party/rust/target-lexicon-0.9.0/examples/misc.rs @@ -0,0 +1,14 @@ +extern crate target_lexicon; + +use core::str::FromStr; +use target_lexicon::{Triple, HOST}; + +fn main() { + println!("The host triple is {}.", HOST); + + let e = Triple::from_str("riscv32-unknown-unknown") + .expect("expected to recognize the RISC-V target") + .endianness() + .expect("expected to know the endianness of RISC-V"); + println!("The endianness of RISC-V is {:?}.", e); +} |