rust/example/std_example.rs

51 lines
1.2 KiB
Rust
Raw Normal View History

2019-02-16 08:42:20 -06:00
#![feature(core_intrinsics)]
2019-02-11 12:40:07 -06:00
use std::io::Write;
fn main() {
let _ = ::std::iter::repeat('a' as u8).take(10).collect::<Vec<_>>();
let stderr = ::std::io::stderr();
let mut stderr = stderr.lock();
writeln!(stderr, "some {} text", "<unknown>").unwrap();
2019-02-16 07:02:15 -06:00
2019-02-16 08:42:20 -06:00
let _ = std::process::Command::new("true").env("c", "d").spawn();
println!("cargo:rustc-link-lib=z");
2019-02-16 09:24:03 -06:00
static ONCE: std::sync::Once = std::sync::ONCE_INIT;
ONCE.call_once(|| {});
LoopState::Continue(()) == LoopState::Break(());
// Make sure ByValPair values with differently sized components are correctly passed
map(None::<(u8, Box<Instruction>)>);
2019-06-25 13:18:10 -05:00
println!("{}", 2.3f32.exp());
println!("{}", 2.3f32.exp2());
println!("{}", 2.3f32.abs());
println!("{}", 2.3f32.sqrt());
println!("{}", 2.3f32.floor());
println!("{}", 2.3f32.ceil());
println!("{}", 2.3f32.min(1.0));
println!("{}", 2.3f32.max(1.0));
}
#[derive(PartialEq)]
enum LoopState {
Continue(()),
Break(())
2019-02-11 12:40:07 -06:00
}
pub enum Instruction {
Increment,
Loop,
}
fn map(a: Option<(u8, Box<Instruction>)>) -> Option<Box<Instruction>> {
match a {
None => None,
Some((_, instr)) => Some(instr),
}
}