Initially taken by Niko Matsakis and lightly edited by Ryan Levick
- Introductions
- Cargo inside large build systems
- FFI
- Foundations and financial support
use std::str; | |
fn main() { | |
// -- FROM: vec of chars -- | |
let src1: Vec<char> = vec!['j','{','"','i','m','m','y','"','}']; | |
// to String | |
let string1: String = src1.iter().collect::<String>(); | |
// to str | |
let str1: &str = &src1.iter().collect::<String>(); | |
// to vec of byte |
impl< | |
'four>For for | |
& 'four for< | |
'fore>For where | |
for<'fore>For:For | |
{fn four( self:&& | |
'four for <'fore> | |
For){ print!( | |
"four" )}} fn | |
main(){ four(&( |
#![feature(generators)] | |
#![feature(generator_trait)] | |
use std::ops::{Generator, GeneratorState}; | |
fn fizzbuzz_println(upto: u64) { | |
for i in 0..upto { | |
if i % 3 == 0 && i % 5 == 0 { | |
println!("FizzBuzz"); | |
} else if i % 3 == 0 { |
#![warn(rust_2018_idioms)] | |
#[derive(Debug)] | |
pub struct StrSplit<'haystack, D> { | |
remainder: Option<&'haystack str>, | |
delimiter: D, | |
} | |
impl<'haystack, D> StrSplit<'haystack, D> { | |
pub fn new(haystack: &'haystack str, delimiter: D) -> Self { |
pub struct Monster { | |
hp: u8, // health points | |
sp: u8, // spell points | |
friends: Vec<Friend>, | |
} | |
pub struct Friend { | |
loyalty: u8, | |
} |
pub struct Monster { | |
hp: u8, // health points | |
sp: u8, // spell points | |
friends: Vec<Friend>, | |
} | |
pub struct Friend { | |
loyalty: u8, | |
} |
trait A{ | |
fn a(&self); | |
} | |
trait B{ | |
fn b(&self); | |
} | |
impl B for A{ |
fn t() -> Result<bool, ()> { | |
Ok( | |
Ok(true)? && Ok(true)? | |
) | |
} | |
fn main(){ |
use std::collections::HashMap; | |
use std::thread; | |
use std::time::Instant; | |
const NUM_ELEMENTS: usize = 1000000; | |
type HeavyThings = HashMap<usize, Vec<usize>>; | |
fn main() { | |
let heavy_things_1 = make_heavy_things(); |