Skip to content

Instantly share code, notes, and snippets.

View rust-play's full-sized avatar

The Rust Playground rust-play

View GitHub Profile
@rust-play
rust-play / playground.rs
Created March 13, 2018 23:51
Code shared from the Rust Playground
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.iter() {
println!("{}", &region);
@rust-play
rust-play / playground.rs
Created March 13, 2018 23:57
Code shared from the Rust Playground
use lexer::lex_token;
use lexer::lexer_parts::literal_lexer;
use constants::TokenTypes;
use constants::operations::OPARRAY;
use constants::delimiters::SEMICOLON;
use constants::datatypes::DATATYPESARRAY;
use constants::reserved_constants::RESERVEDCONSTANTSARRAY;
use constants::accessident::ACCESSIDENTARRAY;
use lexer::lexer_parts::data_type_lexer;
use lexer::lexer_parts::op_token_lexer;
@rust-play
rust-play / playground.rs
Created March 13, 2018 23:57
Code shared from the Rust Playground
use lexer::lex_token;
use lexer::lexer_parts::literal_lexer;
use constants::TokenTypes;
use constants::operations::OPARRAY;
use constants::delimiters::SEMICOLON;
use constants::datatypes::DATATYPESARRAY;
use constants::reserved_constants::RESERVEDCONSTANTSARRAY;
use constants::accessident::ACCESSIDENTARRAY;
use lexer::lexer_parts::data_type_lexer;
use lexer::lexer_parts::op_token_lexer;
@rust-play
rust-play / playground.rs
Created March 13, 2018 23:59
Code shared from the Rust Playground
use lexer::lex_token;
use lexer::lexer_parts::literal_lexer;
use constants::TokenTypes;
use constants::operations::OPARRAY;
use constants::delimiters::SEMICOLON;
use constants::datatypes::DATATYPESARRAY;
use constants::reserved_constants::RESERVEDCONSTANTSARRAY;
use lexer::lexer_parts::data_type_lexer;
use lexer::lexer_parts::op_token_lexer;
use lexer::lexer_parts::end_token_lexer;
@rust-play
rust-play / playground.rs
Created March 14, 2018 00:21
Code shared from the Rust Playground
extern crate chrono;
extern crate rand;
use std::rc::Rc;
use std::mem;
use List::{Cons, Nil};
use chrono::*;
use std::collections::HashMap;
use std::fmt::Display;
use rand::Rng;
@rust-play
rust-play / playground.rs
Created March 14, 2018 00:50
Code shared from the Rust Playground
fn foo<'a, I>(grr: I) where I: Iterator<Item=&'a str> {
let numbers = grr.map(str::parse::<f64>);
}
fn main() {}
@rust-play
rust-play / playground.rs
Created March 14, 2018 00:51
Code shared from the Rust Playground
fn foo<'a, I>(grr: I) where I: Iterator<Item=String> {
let numbers = grr.map(|s| s.parse::<f64>());
}
fn main() {}
@rust-play
rust-play / playground.rs
Created March 14, 2018 00:59
Code shared from the Rust Playground
#![feature(specialization)]
trait Foo<T: DefaultFooBehavior> {
fn bar() {
T::do_stuff();
}
}
trait DefaultFooBehavior {
fn do_stuff();
@rust-play
rust-play / playground.rs
Created March 14, 2018 01:01
Code shared from the Rust Playground
#![feature(specialization)]
struct Baz;
trait Foo<T> {
fn bar();
}
default impl<T> Foo<Baz> for T {
fn bar() {
@rust-play
rust-play / playground.rs
Created March 14, 2018 01:03
Code shared from the Rust Playground
use std::fmt::Display;
trait Bar<T: Display> {
fn foo(&self, s: T) {
println!("{}", s)
}
}
struct Foo;