View playground.rs
pub struct Um { | |
gus: i64, | |
} | |
fn main() { | |
let u = Um{gus: 7}; | |
let a: i64 = u.gus; | |
match 7 { |
View playground.rs
fn func<T: ?Sized>() { | |
eprintln!("Size: {}", std::mem::size_of::<&T>()); | |
} | |
trait Whatever {} | |
fn main() { | |
func::<usize>(); | |
func::<[usize]>(); | |
func::<dyn Whatever>(); |
View playground.rs
fn func<T: ?Sized>() { | |
eprintln!("Size: {}", std::mem::size_of::<&T>()); | |
} | |
fn main() { | |
func::<usize>(); | |
func::<[usize]>(); | |
} |
View playground.rs
macro_rules! test_cases { | |
(@ [ :: $variant:ident :: stream :: compress ]) => { | |
#[test] fn a() { } | |
}; | |
(@ [ :: $variant:ident :: futures :: write :: compress ]) => { | |
#[test] fn b() { } | |
}; | |
(@ [ :: $variant:ident :: futures :: write :: decompress ]) => { |
View playground.rs
struct MyStruct<TCollection> | |
where | |
for<'a> &'a TCollection: IntoIterator<Item = &'a ()>, | |
{ | |
references: TCollection, | |
} | |
impl<TCollection> Drop for MyStruct<TCollection> | |
where | |
for<'b> &'b TCollection: IntoIterator<Item = &'b ()>, |
View playground.rs
pub mod zero_sized { | |
use std::marker::PhantomData; | |
pub struct ZeroSizeProof<T>(PhantomData<T>, ()); | |
pub trait ZeroSized: Sized { | |
#[deny(const_err)] | |
const I_AM_ZERO_SIZED: (); | |
fn proof_zero_size(&self) -> ZeroSizeProof<Self>; | |
} |
View playground.rs
struct MyStruct<TCollection> | |
where | |
for<'a> &'a TCollection: IntoIterator<Item = &'a ()>, | |
{ | |
references: TCollection, | |
} | |
impl<TCollection> Drop for MyStruct<TCollection> | |
where | |
for<'b> &'b TCollection: IntoIterator<Item = &'b ()>, |
View playground.rs
use std::collections::HashMap; | |
struct Foo { | |
d: HashMap<String, f32> | |
} | |
impl Foo { | |
fn get(&mut self, s: &str) -> Option<&f32> { | |
if !self.d.contains_key(s) { | |
self.d.insert(s.to_string(), 0.0); |
View playground.rs
use std::iter::Peekable; | |
use std::str::Chars; | |
pub enum Token { | |
E, | |
Rest, | |
} | |
pub struct Lexer<'a> { | |
chars: Peekable<Chars<'a>>, |
View playground.rs
struct Foo<F=()>(Vec<F>); | |
fn do_stuff() { | |
let foo = Foo(); | |
} |
NewerOlder