This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::path::Path; | |
use std::io::Read; | |
pub struct AnimalFile<P> { | |
reader: P, | |
} | |
impl<P> AnimalFile<P> | |
where | |
P: NewBufRead<std::fs::File>, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::{ | |
borrow::{Borrow, Cow}, | |
fmt::Debug, | |
}; | |
fn say<'a, C, B>(first_name: C, last_name: &B) | |
where | |
C: Into<Cow<'a, str>> + Debug + ?Sized, | |
B: Borrow<str> + Debug + ?Sized, | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::cell::RefCell; | |
use std::rc::Rc; | |
pub struct MyStruct { | |
name: String, | |
} | |
fn error_fn() { | |
let mut ms = MyStruct { | |
name: "Before".to_owned(), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[derive(Clone, Copy)] | |
pub struct MyStruct<'a> { | |
name: &'a str, | |
} | |
impl<'a> MyStruct<'a> { | |
fn new() -> Self { | |
MyStruct { name: "Before" } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub struct MyStruct<'a> { | |
name: &'a str, | |
} | |
impl<'a> MyStruct<'a> { | |
fn new() -> Self { | |
MyStruct { name: "Before" } | |
} | |
fn read(&self) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub struct MyStruct<T> { | |
pub value: T, | |
} | |
impl MyStruct<u32> { | |
fn new(value: u32) -> Self { | |
MyStruct { value } | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::fmt::{Debug, Formatter}; | |
pub struct MyStruct<T> { | |
pub value: T, | |
} | |
impl<T> MyStruct<T> { | |
fn new(v: T) -> Self { | |
MyStruct { value: v } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use futures::future::{Future, ok, select_ok}; // 0.1.26 | |
use tokio; // 0.1.18 | |
use tokio_timer::sleep; // 0.2.10 | |
use std::time::Duration; | |
fn i() -> impl Future<Item=(), Error=()> { | |
print!("Immediate\n"); | |
ok(()) | |
} | |
fn d() -> impl Future<Item=(), Error=()> { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use futures::sync::oneshot::{channel, Receiver, Sender}; | |
use futures::{ | |
future::{lazy, ok, Future}, | |
Async, Poll, | |
}; | |
use tokio; | |
use tokio_timer::sleep; | |
use std::time::Duration; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use futures::{ | |
future::{lazy, ok, Future}, | |
Async, Poll, | |
}; | |
use std::time::Duration; | |
use tokio; | |
use tokio_timer::sleep; | |
use std::sync::atomic::{AtomicBool, Ordering}; | |
use std::sync::Arc; |
NewerOlder