Skip to content

Instantly share code, notes, and snippets.

The Rust Playground rust-play

Block or report user

Report or block rust-play

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@rust-play
rust-play / playground.rs
Created Aug 25, 2019
Code shared from the Rust Playground
View playground.rs
#[allow(const_err)]
fn main() {
println!("{}", std::i32::MAX + std::i32::MAX);
}
@rust-play
rust-play / playground.rs
Created Aug 25, 2019
Code shared from the Rust Playground
View playground.rs
fn main() {
println!("{}", std::mem::size_of::<Box<i32>>());
println!("{}", std::mem::size_of::<Box<[i32; 42]>>());
println!("{}", std::mem::size_of::<Box<[i32]>>());
}
@rust-play
rust-play / playground.rs
Created Aug 25, 2019
Code shared from the Rust Playground
View playground.rs
use std::convert::TryInto;
fn main() {
let x: i64 = -30;
let y: u64 = x.try_into().unwrap();
println!("{}", y);
}
@rust-play
rust-play / playground.rs
Created Aug 25, 2019
Code shared from the Rust Playground
View playground.rs
#![allow(unreachable_code)]
fn main() {
println!("{:?}", {
fn breed_cow<'a, 'b>(a: std::borrow::Cow<'a, str>) -> std::borrow::Cow<'b, str> { a.clone() }
});
}
@rust-play
rust-play / playground.rs
Created Aug 25, 2019
Code shared from the Rust Playground
View playground.rs
#![allow(unreachable_code)]
fn main() {
println!("{:?}", {
fn breed_cow<'a, 'b>(a: std::borrow::Cow<'a, str>) -> std::borrow::Cow<'b, str> { a.clone() }
});
}
@rust-play
rust-play / playground.rs
Created Aug 25, 2019
Code shared from the Rust Playground
View playground.rs
fn main() {
println!("Hello, world!");
}
@rust-play
rust-play / playground.rs
Created Aug 25, 2019
Code shared from the Rust Playground
View playground.rs
fn main() {
let b: &'static [u8; 0] = b"";
let s: &[u8] = b;
}
@rust-play
rust-play / playground.rs
Created Aug 25, 2019
Code shared from the Rust Playground
View playground.rs
fn main() {
let b: &'static [u8; 0] = b"";
let s: &[u8] = b.as_ref();
}
@rust-play
rust-play / playground.rs
Created Aug 25, 2019
Code shared from the Rust Playground
View playground.rs
fn assert_type<T>(_: T) {}
fn main() {
let a: &[u8] = &[];
let b: &[u8] = b"";
assert_type::<&[u8]>(a);
assert_type::<&[u8]>(b);
assert_eq!(a, b);
@rust-play
rust-play / playground.rs
Created Aug 25, 2019
Code shared from the Rust Playground
View playground.rs
struct A<'b>{
a: &'b [u8]
}
fn main() {
println!("{}", std::mem::size_of::<A>());
}
You can’t perform that action at this time.