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::{Async, AsyncSink, Future, Sink}; | |
use tokio::io::AsyncWrite; | |
use std::io; | |
pub struct ByteSink<W: AsyncWrite>(W); | |
impl<W: AsyncWrite> ByteSink<W> { | |
pub fn new(writer: W) -> Self { | |
ByteSink(writer) |
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::ok, try_ready, Async, Future, Poll, Stream}; | |
use tokio::io::AsyncRead; | |
use std::io; | |
pub struct ByteStream<R: AsyncRead>(R); | |
impl<R: AsyncRead> ByteStream<R> { | |
pub fn new(reader: R) -> Self { | |
ByteStream(reader) |
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; |
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::{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 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
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
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
#[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
use std::cell::RefCell; | |
use std::rc::Rc; | |
pub struct MyStruct { | |
name: String, | |
} | |
fn error_fn() { | |
let mut ms = MyStruct { | |
name: "Before".to_owned(), |
OlderNewer