Skip to content

Instantly share code, notes, and snippets.

let quit_send = self.quit_send.clone();
io.add_method("quit", move |_| {
let quit_send = quit_send.clone();
async move {
quit_send.send(()).await;
Ok(jsonrpc_core::Value::Null)
}
});
#lang racket
(define (create_local ident)
(printf "value: ~a\n" ident)
110
)
(define (foo) (
(let ([local (create_local 'x)])
(displayln "hihi")
error: cannot infer an appropriate lifetime
--> examples/client.rs:84:20
|
84 | async fn start(&self) -> io::Result<()> {
| ^^^^^ ...but this borrow...
...
90 | let _ = smol::Task::spawn(self.wait_shutdown_signal(stopped.clone()));
| ----------------- this return type evaluates to the `'static` lifetime...
|
note: ...can't outlive the lifetime `'_` as defined on the method body at 84:20
impl<T: Send + 'static> Task<T> {
/// Spawns a future onto the work-stealing executor.
///
/// This future may be stolen and polled by any thread calling [`run()`].
///
/// # Examples
///
/// ```
/// use smol::Task;
///
struct TitanClient {
}
impl TitanClient {
fn new() -> Self {
TitanClient {
}
}
fn stop(&self) {
struct Special
{
}
trait Trait
{
fn foo(&self);
}
impl<T> Trait for T
use futures::io;
use smol::{Async, Task, Timer};
use std::net::{TcpListener, TcpStream};
use std::thread;
use std::time::Duration;
async fn echo(stream: Async<TcpStream>) -> io::Result<()> {
Timer::after(Duration::from_secs(5)).await;
println!("sleep over");
io::copy(&stream, &mut &stream).await?;
use std::net::TcpStream;
use futures::io;
use futures::prelude::*;
use smol::{Async, Timer};
use std::time::Duration;
async fn sleep(seconds: u64) {
Timer::after(Duration::from_secs(seconds)).await;
}
#![feature(pin, arbitrary_self_types, optin_builtin_traits)]
use std::ptr;
use std::mem::Pin;
use std::boxed::PinBox;
use std::marker::Unpin;
struct SelfReferential {
data: i32,
self_ref: *const i32,
struct Network {
}
struct Handshake<'a> {
net: &'a Network
}
struct Foo<'a> {
net: Network,
hs: Handshake<'a>