View playground.rs
enum Foo {
A,
B
}
impl Foo {
fn foo(&self) {
match self {
Self::A => (),
Self::B => ()
View playground.rs
extern crate futures; // 0.1.21
extern crate h2; // 0.1.10
extern crate http; // 0.1.7
extern crate tokio;
use futures::{Future, Stream};
use h2::server;
use http::{Response, StatusCode};
use tokio::net::TcpListener;
View playground.rs
macro_rules! t {
($(#[$attr:meta])* $name:ident($pattern:expr, [$($file:expr),*])) => {
$(#[$attr])*
fn $name() {
let pattern = $pattern;
let files = vec![$(concat!(stringify!($name),"_",$file)),*];
process_grep_case(pattern, &files);
panic!("we want to see the output")
View playground.rs
struct Bar<'a> {
mutator: Box<FnMut() + 'a>,
}
trait Foo<'a> {
fn do_foo(&'a mut self) -> Bar<'a>;
}
fn main() {}
View playground.rs
fn main() {
let some_string = convert(vec!["one", "two", "three"]);
println!("{}", some_string);
}
//Doesn't Work
pub fn convert<T>(values: Vec<T>) -> String
where
T: Into<String>,
{
View playground.rs
#![allow(unused)]
#![doc(hi)]
fn main() {
let mut /* hi */ x: i8 = 120;
x += 10;
if
/* x */
x > 10 {
println!("hi\x0a");
}
View playground.rs
fn main() {
let some_string = convert(vec!["one", "two", "three"]);
println!("{}", some_string);
}
//Doesn't Work
pub fn convert<T>(values: Vec<T>) -> String where T: Into<String> {
values.iter()
.collect::<Vec<String>>()
.join(",")
View playground.rs
fn result_sign(v: i32) -> Box<Result<i32, i32>> {
let r = Ok(v)
// this 'map' should be 'and_then'
.map(|v| {
// OR the returns should be raw i32, instead of Ok(i32)
if v > 0 {
Ok(1)
}
else {
View playground.rs
use std::collections::HashMap;
use std::hash::Hash;
pub struct CacheMap<F, T, V>
where F: Fn(&T) -> V, T: Hash + Eq + Copy, V: Copy
{
operation: F,
results: HashMap<T, V>,
}
View playground.rs
use std::thread;
use std::time::Duration;
// Yay multithreading!
// all examples stolen shamelessly from the Rust book
// my first thread example
fn main() {