Skip to content

Instantly share code, notes, and snippets.

View octave99's full-sized avatar

octave99 octave99

View GitHub Profile
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)
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)
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;
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;
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=()> {
use std::fmt::{Debug, Formatter};
pub struct MyStruct<T> {
pub value: T,
}
impl<T> MyStruct<T> {
fn new(v: T) -> Self {
MyStruct { value: v }
}
pub struct MyStruct<T> {
pub value: T,
}
impl MyStruct<u32> {
fn new(value: u32) -> Self {
MyStruct { value }
}
}
pub struct MyStruct<'a> {
name: &'a str,
}
impl<'a> MyStruct<'a> {
fn new() -> Self {
MyStruct { name: "Before" }
}
fn read(&self) {
#[derive(Clone, Copy)]
pub struct MyStruct<'a> {
name: &'a str,
}
impl<'a> MyStruct<'a> {
fn new() -> Self {
MyStruct { name: "Before" }
}
use std::cell::RefCell;
use std::rc::Rc;
pub struct MyStruct {
name: String,
}
fn error_fn() {
let mut ms = MyStruct {
name: "Before".to_owned(),