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 Mar 11, 2018
Code shared from the Rust Playground
View playground.rs
This is only a test
@rust-play
rust-play / playground.rs
Created Mar 12, 2018
Code shared from the Rust Playground
View playground.rs
struct t{
a: u32,
b: u32
}
fn main() {
let mut test: t;
test.a = 16;
test.b = 12;
let res: u32 = test.a*test.b;
@rust-play
rust-play / playground.rs
Created Mar 12, 2018
Code shared from the Rust Playground
View playground.rs
struct Test {
a: u32,
b: u32,
}
impl Test {
fn new(a: u32, b: u32) -> Test {
Test { a, b }
}
}
@rust-play
rust-play / playground.rs
Created Mar 12, 2018
Code shared from the Rust Playground
View playground.rs
#![feature(specialization)]
pub struct MemberBase {
id: u32,
}
impl MemberBase {
pub fn id(&self) -> u32 { self.id }
}
pub trait UiMemberSpecialization {
fn size(&self) -> (u32, u32);
@rust-play
rust-play / playground.rs
Created Mar 12, 2018
Code shared from the Rust Playground
View playground.rs
struct Testing{
one: Option<String>
}
impl Testing {
/// redis://[:<passwd>@]<hostname>[:port][/<db>]
pub fn do_something(&self) {
let one = &self.one.unwrap_or_default();
println!("one is: {:?}", one);
@rust-play
rust-play / playground.rs
Created Mar 12, 2018
Code shared from the Rust Playground
View playground.rs
struct Testing{
one: Option<String>
}
impl Testing {
/// redis://[:<passwd>@]<hostname>[:port][/<db>]
pub fn do_something(&self) {
let one = self.one.as_ref().unwrap();
println!("one is: {:?}", one);
@rust-play
rust-play / playground.rs
Created Mar 13, 2018
Code shared from the Rust Playground
View playground.rs
fn main() {
let mut v = vec![1, 2, 3, 4, 5];
let first = &v[0];
v.push(6);
}
@rust-play
rust-play / playground.rs
Created Mar 13, 2018
Code shared from the Rust Playground
View playground.rs
//play.rust-lang.org
fn main() {}
@rust-play
rust-play / playground.rs
Created Mar 13, 2018
Code shared from the Rust Playground
View playground.rs
extern crate chrono;
use chrono::prelude::*;
fn main() {
let datetime = Utc.ymd(2020, 1, 1).and_hms(0, 0, 0);
let timestamp = datetime.timestamp();
let naive_datetime = NaiveDateTime::from_timestamp(timestamp, 0);
let datetime_again: DateTime<Utc> = DateTime::from_utc(naive_datetime, Utc);
println!("{}", datetime_again);
@rust-play
rust-play / playground.rs
Created Mar 13, 2018
Code shared from the Rust Playground
View playground.rs
fn greet_world() {
println!("Hello, world!"); // our old friend.
let southern_germany = "Grüß Gott!";
let japan = "ハロー・ワールド";
let regions = [southern_germany, japan];
for region in &regions {
println!("{}", region);
You can’t perform that action at this time.