mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-26 00:00:16 +02:00
Update Tokio to Rust 2018 (#1082)
This commit is contained in:
@@ -1,15 +1,17 @@
|
||||
#![doc(html_root_url = "https://docs.rs/tokio-sync/0.1.5")]
|
||||
#![deny(missing_debug_implementations, missing_docs, unreachable_pub)]
|
||||
#![deny(
|
||||
missing_debug_implementations,
|
||||
missing_docs,
|
||||
unreachable_pub,
|
||||
rust_2018_idioms
|
||||
)]
|
||||
#![cfg_attr(test, deny(warnings))]
|
||||
#![doc(test(no_crate_inject, attr(deny(rust_2018_idioms))))]
|
||||
|
||||
//! Asynchronous synchronization primitives.
|
||||
//!
|
||||
//! This crate provides primitives for synchronizing asynchronous tasks.
|
||||
|
||||
extern crate fnv;
|
||||
#[macro_use]
|
||||
extern crate futures;
|
||||
|
||||
macro_rules! debug {
|
||||
($($t:tt)*) => {
|
||||
if false {
|
||||
|
||||
@@ -8,11 +8,9 @@
|
||||
//! This allows you to do something along the lines of:
|
||||
//!
|
||||
//! ```rust,no_run
|
||||
//! # #[macro_use]
|
||||
//! # extern crate futures;
|
||||
//! # extern crate tokio;
|
||||
//! # use futures::{future, Poll, Async, Future, Stream};
|
||||
//! use futures::{try_ready, future, Poll, Async, Future, Stream};
|
||||
//! use tokio::sync::lock::{Lock, LockGuard};
|
||||
//!
|
||||
//! struct MyType<S> {
|
||||
//! lock: Lock<S>,
|
||||
//! }
|
||||
@@ -37,14 +35,13 @@
|
||||
//! }
|
||||
//! }
|
||||
//! }
|
||||
//! # fn main() {}
|
||||
//! ```
|
||||
//!
|
||||
//! [`Lock`]: struct.Lock.html
|
||||
//! [`LockGuard`]: struct.LockGuard.html
|
||||
//! [`Lock`]: struct.Lock.html
|
||||
//! [`LockGuard`]: struct.LockGuard.html
|
||||
|
||||
use crate::semaphore;
|
||||
use futures::Async;
|
||||
use semaphore;
|
||||
use std::cell::UnsafeCell;
|
||||
use std::fmt;
|
||||
use std::ops::{Deref, DerefMut};
|
||||
@@ -176,7 +173,7 @@ impl<T> DerefMut for LockGuard<T> {
|
||||
}
|
||||
|
||||
impl<T: fmt::Display> fmt::Display for LockGuard<T> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
fmt::Display::fmt(&**self, f)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
pub(crate) mod futures {
|
||||
pub(crate) use crate::task::AtomicTask;
|
||||
pub(crate) use futures::task;
|
||||
pub(crate) use task::AtomicTask;
|
||||
}
|
||||
|
||||
pub(crate) mod sync {
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
use loom::{
|
||||
use crate::loom::{
|
||||
self,
|
||||
sync::atomic::{AtomicPtr, AtomicUsize},
|
||||
sync::CausalCell,
|
||||
};
|
||||
|
||||
use std::mem::{self, ManuallyDrop};
|
||||
use std::ops;
|
||||
use std::ptr::{self, NonNull};
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
use super::chan;
|
||||
|
||||
use futures::{Poll, Sink, StartSend, Stream};
|
||||
|
||||
use std::fmt;
|
||||
|
||||
/// Send values to the associated `Receiver`.
|
||||
@@ -20,7 +18,7 @@ impl<T> Clone for Sender<T> {
|
||||
}
|
||||
|
||||
impl<T> fmt::Debug for Sender<T> {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
fmt.debug_struct("Sender")
|
||||
.field("chan", &self.chan)
|
||||
.finish()
|
||||
@@ -36,7 +34,7 @@ pub struct Receiver<T> {
|
||||
}
|
||||
|
||||
impl<T> fmt::Debug for Receiver<T> {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
fmt.debug_struct("Receiver")
|
||||
.field("chan", &self.chan)
|
||||
.finish()
|
||||
@@ -80,9 +78,6 @@ pub struct RecvError(());
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// extern crate futures;
|
||||
/// extern crate tokio;
|
||||
///
|
||||
/// use tokio::sync::mpsc::channel;
|
||||
/// use tokio::prelude::*;
|
||||
/// use futures::future::lazy;
|
||||
@@ -114,7 +109,7 @@ pub struct RecvError(());
|
||||
/// ```
|
||||
pub fn channel<T>(buffer: usize) -> (Sender<T>, Receiver<T>) {
|
||||
assert!(buffer > 0, "mpsc bounded channel requires buffer > 0");
|
||||
let semaphore = (::semaphore::Semaphore::new(buffer), buffer);
|
||||
let semaphore = (crate::semaphore::Semaphore::new(buffer), buffer);
|
||||
let (tx, rx) = chan::channel(semaphore);
|
||||
|
||||
let tx = Sender::new(tx);
|
||||
@@ -125,7 +120,7 @@ pub fn channel<T>(buffer: usize) -> (Sender<T>, Receiver<T>) {
|
||||
|
||||
/// Channel semaphore is a tuple of the semaphore implementation and a `usize`
|
||||
/// representing the channel bound.
|
||||
type Semaphore = (::semaphore::Semaphore, usize);
|
||||
type Semaphore = (crate::semaphore::Semaphore, usize);
|
||||
|
||||
impl<T> Receiver<T> {
|
||||
pub(crate) fn new(chan: chan::Rx<T, Semaphore>) -> Receiver<T> {
|
||||
@@ -218,7 +213,7 @@ impl<T> Sink for Sender<T> {
|
||||
// ===== impl SendError =====
|
||||
|
||||
impl fmt::Display for SendError {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
use std::error::Error;
|
||||
write!(fmt, "{}", self.description())
|
||||
}
|
||||
@@ -258,7 +253,7 @@ impl<T> TrySendError<T> {
|
||||
}
|
||||
|
||||
impl<T: fmt::Debug> fmt::Display for TrySendError<T> {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
use std::error::Error;
|
||||
write!(fmt, "{}", self.description())
|
||||
}
|
||||
@@ -288,7 +283,7 @@ impl<T> From<(T, chan::TrySendError)> for TrySendError<T> {
|
||||
// ===== impl RecvError =====
|
||||
|
||||
impl fmt::Display for RecvError {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
use std::error::Error;
|
||||
write!(fmt, "{}", self.description())
|
||||
}
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
use super::list;
|
||||
use futures::Poll;
|
||||
|
||||
use loom::{
|
||||
use crate::loom::{
|
||||
futures::AtomicTask,
|
||||
sync::atomic::AtomicUsize,
|
||||
sync::{Arc, CausalCell},
|
||||
};
|
||||
|
||||
use futures::Poll;
|
||||
use std::fmt;
|
||||
use std::process;
|
||||
use std::sync::atomic::Ordering::{AcqRel, Relaxed};
|
||||
@@ -22,7 +20,7 @@ where
|
||||
S::Permit: fmt::Debug,
|
||||
S: fmt::Debug,
|
||||
{
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
fmt.debug_struct("Tx")
|
||||
.field("inner", &self.inner)
|
||||
.field("permit", &self.permit)
|
||||
@@ -39,7 +37,7 @@ impl<T, S: Semaphore> fmt::Debug for Rx<T, S>
|
||||
where
|
||||
S: fmt::Debug,
|
||||
{
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
fmt.debug_struct("Rx").field("inner", &self.inner).finish()
|
||||
}
|
||||
}
|
||||
@@ -99,7 +97,7 @@ impl<T, S> fmt::Debug for Chan<T, S>
|
||||
where
|
||||
S: fmt::Debug,
|
||||
{
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
fmt.debug_struct("Chan")
|
||||
.field("tx", &self.tx)
|
||||
.field("semaphore", &self.semaphore)
|
||||
@@ -120,7 +118,7 @@ struct RxFields<T> {
|
||||
}
|
||||
|
||||
impl<T> fmt::Debug for RxFields<T> {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
fmt.debug_struct("RxFields")
|
||||
.field("list", &self.list)
|
||||
.field("rx_closed", &self.rx_closed)
|
||||
@@ -337,7 +335,7 @@ impl<T, S> Drop for Chan<T, S> {
|
||||
}
|
||||
}
|
||||
|
||||
use semaphore::TryAcquireError;
|
||||
use crate::semaphore::TryAcquireError;
|
||||
|
||||
impl From<TryAcquireError> for TrySendError {
|
||||
fn from(src: TryAcquireError) -> TrySendError {
|
||||
@@ -353,9 +351,9 @@ impl From<TryAcquireError> for TrySendError {
|
||||
|
||||
// ===== impl Semaphore for (::Semaphore, capacity) =====
|
||||
|
||||
use semaphore::Permit;
|
||||
use crate::semaphore::Permit;
|
||||
|
||||
impl Semaphore for (::semaphore::Semaphore, usize) {
|
||||
impl Semaphore for (crate::semaphore::Semaphore, usize) {
|
||||
type Permit = Permit;
|
||||
|
||||
fn new_permit() -> Permit {
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
//! A concurrent, lock-free, FIFO list.
|
||||
|
||||
use super::block::{self, Block};
|
||||
|
||||
use loom::{
|
||||
use crate::loom::{
|
||||
self,
|
||||
sync::atomic::{AtomicPtr, AtomicUsize},
|
||||
};
|
||||
|
||||
use std::fmt;
|
||||
use std::ptr::NonNull;
|
||||
use std::sync::atomic::Ordering::{AcqRel, Acquire, Relaxed, Release};
|
||||
@@ -214,7 +212,7 @@ impl<T> Tx<T> {
|
||||
}
|
||||
|
||||
impl<T> fmt::Debug for Tx<T> {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
fmt.debug_struct("Tx")
|
||||
.field("block_tail", &self.block_tail.load(Relaxed))
|
||||
.field("tail_position", &self.tail_position.load(Relaxed))
|
||||
@@ -339,7 +337,7 @@ impl<T> Rx<T> {
|
||||
}
|
||||
|
||||
impl<T> fmt::Debug for Rx<T> {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
fmt.debug_struct("Rx")
|
||||
.field("head", &self.head)
|
||||
.field("index", &self.index)
|
||||
|
||||
@@ -41,14 +41,12 @@ mod list;
|
||||
mod unbounded;
|
||||
|
||||
pub use self::bounded::{channel, Receiver, Sender};
|
||||
|
||||
pub use self::unbounded::{unbounded_channel, UnboundedReceiver, UnboundedSender};
|
||||
|
||||
pub mod error {
|
||||
//! Channel error types
|
||||
|
||||
pub use super::bounded::{RecvError, SendError, TrySendError};
|
||||
|
||||
pub use super::unbounded::{UnboundedRecvError, UnboundedSendError, UnboundedTrySendError};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
use super::chan;
|
||||
|
||||
use crate::loom::sync::atomic::AtomicUsize;
|
||||
use futures::{Poll, Sink, StartSend, Stream};
|
||||
use loom::sync::atomic::AtomicUsize;
|
||||
|
||||
use std::fmt;
|
||||
|
||||
/// Send values to the associated `UnboundedReceiver`.
|
||||
@@ -22,7 +20,7 @@ impl<T> Clone for UnboundedSender<T> {
|
||||
}
|
||||
|
||||
impl<T> fmt::Debug for UnboundedSender<T> {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
fmt.debug_struct("UnboundedSender")
|
||||
.field("chan", &self.chan)
|
||||
.finish()
|
||||
@@ -39,7 +37,7 @@ pub struct UnboundedReceiver<T> {
|
||||
}
|
||||
|
||||
impl<T> fmt::Debug for UnboundedReceiver<T> {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
fmt.debug_struct("UnboundedReceiver")
|
||||
.field("chan", &self.chan)
|
||||
.finish()
|
||||
@@ -140,7 +138,7 @@ impl<T> Sink for UnboundedSender<T> {
|
||||
// ===== impl UnboundedSendError =====
|
||||
|
||||
impl fmt::Display for UnboundedSendError {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
use std::error::Error;
|
||||
write!(fmt, "{}", self.description())
|
||||
}
|
||||
@@ -162,7 +160,7 @@ impl<T> UnboundedTrySendError<T> {
|
||||
}
|
||||
|
||||
impl<T: fmt::Debug> fmt::Display for UnboundedTrySendError<T> {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
use std::error::Error;
|
||||
write!(fmt, "{}", self.description())
|
||||
}
|
||||
@@ -184,7 +182,7 @@ impl<T> From<(T, chan::TrySendError)> for UnboundedTrySendError<T> {
|
||||
// ===== impl UnboundedRecvError =====
|
||||
|
||||
impl fmt::Display for UnboundedRecvError {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
use std::error::Error;
|
||||
write!(fmt, "{}", self.description())
|
||||
}
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
//! A channel for sending a single message between asynchronous tasks.
|
||||
|
||||
use loom::{
|
||||
use crate::loom::{
|
||||
futures::task::{self, Task},
|
||||
sync::atomic::AtomicUsize,
|
||||
sync::CausalCell,
|
||||
};
|
||||
|
||||
use futures::{Async, Future, Poll};
|
||||
|
||||
use std::fmt;
|
||||
use std::mem::{self, ManuallyDrop};
|
||||
use std::sync::atomic::Ordering::{self, AcqRel, Acquire};
|
||||
@@ -45,7 +43,7 @@ pub mod error {
|
||||
// ===== impl RecvError =====
|
||||
|
||||
impl fmt::Display for RecvError {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
use std::error::Error;
|
||||
write!(fmt, "{}", self.description())
|
||||
}
|
||||
@@ -60,7 +58,7 @@ pub mod error {
|
||||
// ===== impl TryRecvError =====
|
||||
|
||||
impl fmt::Display for TryRecvError {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
use std::error::Error;
|
||||
write!(fmt, "{}", self.description())
|
||||
}
|
||||
@@ -105,9 +103,6 @@ struct State(usize);
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// extern crate futures;
|
||||
/// extern crate tokio;
|
||||
///
|
||||
/// use tokio::sync::oneshot;
|
||||
/// use futures::Future;
|
||||
/// use std::thread;
|
||||
@@ -451,7 +446,7 @@ impl<T> Drop for Inner<T> {
|
||||
}
|
||||
|
||||
impl<T: fmt::Debug> fmt::Debug for Inner<T> {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
use std::sync::atomic::Ordering::Relaxed;
|
||||
|
||||
fmt.debug_struct("Inner")
|
||||
@@ -532,7 +527,7 @@ impl State {
|
||||
}
|
||||
|
||||
impl fmt::Debug for State {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
fmt.debug_struct("State")
|
||||
.field("is_complete", &self.is_complete())
|
||||
.field("is_closed", &self.is_closed())
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
//! section. If no permits are available, then acquiring the semaphore returns
|
||||
//! `NotReady`. The task is notified once a permit becomes available.
|
||||
|
||||
use loom::{
|
||||
use crate::loom::{
|
||||
futures::AtomicTask,
|
||||
sync::{
|
||||
atomic::{AtomicPtr, AtomicUsize},
|
||||
@@ -16,9 +16,7 @@ use loom::{
|
||||
},
|
||||
yield_now,
|
||||
};
|
||||
|
||||
use futures::Poll;
|
||||
|
||||
use std::fmt;
|
||||
use std::ptr::{self, NonNull};
|
||||
use std::sync::atomic::Ordering::{self, AcqRel, Acquire, Relaxed, Release};
|
||||
@@ -531,7 +529,7 @@ impl Semaphore {
|
||||
}
|
||||
|
||||
impl fmt::Debug for Semaphore {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
fmt.debug_struct("Semaphore")
|
||||
.field("state", &SemState::load(&self.state, Relaxed))
|
||||
.field("head", &self.head.with(|ptr| ptr))
|
||||
@@ -683,7 +681,7 @@ fn to_try_acquire(_: AcquireError) -> TryAcquireError {
|
||||
}
|
||||
|
||||
impl fmt::Display for AcquireError {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
use std::error::Error;
|
||||
write!(fmt, "{}", self.description())
|
||||
}
|
||||
@@ -729,7 +727,7 @@ impl TryAcquireError {
|
||||
}
|
||||
|
||||
impl fmt::Display for TryAcquireError {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
use std::error::Error;
|
||||
write!(fmt, "{}", self.description())
|
||||
}
|
||||
@@ -1073,7 +1071,7 @@ impl SemState {
|
||||
}
|
||||
|
||||
impl fmt::Debug for SemState {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let mut fmt = fmt.debug_struct("SemState");
|
||||
|
||||
if self.is_waiter() {
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
use loom::{
|
||||
use crate::loom::{
|
||||
futures::task::{self, Task},
|
||||
sync::atomic::AtomicUsize,
|
||||
sync::CausalCell,
|
||||
};
|
||||
|
||||
use std::fmt;
|
||||
use std::sync::atomic::Ordering::{AcqRel, Acquire, Release};
|
||||
|
||||
@@ -290,7 +289,7 @@ impl Default for AtomicTask {
|
||||
}
|
||||
|
||||
impl fmt::Debug for AtomicTask {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(fmt, "AtomicTask")
|
||||
}
|
||||
}
|
||||
|
||||
+8
-15
@@ -18,9 +18,6 @@
|
||||
//! # Examples
|
||||
//!
|
||||
//! ```
|
||||
//! # extern crate futures;
|
||||
//! extern crate tokio;
|
||||
//!
|
||||
//! use tokio::prelude::*;
|
||||
//! use tokio::sync::watch;
|
||||
//!
|
||||
@@ -58,8 +55,7 @@
|
||||
|
||||
use fnv::FnvHashMap;
|
||||
use futures::task::AtomicTask;
|
||||
use futures::{Async, AsyncSink, Poll, Sink, StartSend, Stream};
|
||||
|
||||
use futures::{try_ready, Async, AsyncSink, Poll, Sink, StartSend, Stream};
|
||||
use std::ops;
|
||||
use std::sync::atomic::AtomicUsize;
|
||||
use std::sync::atomic::Ordering::SeqCst;
|
||||
@@ -97,7 +93,7 @@ pub struct Sender<T> {
|
||||
/// long lived borrows could cause the produce half to block. It is recommended
|
||||
/// to keep the borrow as short lived as possible.
|
||||
#[derive(Debug)]
|
||||
pub struct Ref<'a, T: 'a> {
|
||||
pub struct Ref<'a, T> {
|
||||
inner: RwLockReadGuard<'a, T>,
|
||||
}
|
||||
|
||||
@@ -121,7 +117,7 @@ pub mod error {
|
||||
// ===== impl RecvError =====
|
||||
|
||||
impl fmt::Display for RecvError {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
use std::error::Error;
|
||||
write!(fmt, "{}", self.description())
|
||||
}
|
||||
@@ -136,7 +132,7 @@ pub mod error {
|
||||
// ===== impl SendError =====
|
||||
|
||||
impl<T: fmt::Debug> fmt::Display for SendError<T> {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
use std::error::Error;
|
||||
write!(fmt, "{}", self.description())
|
||||
}
|
||||
@@ -189,9 +185,6 @@ const CLOSED: usize = 1;
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// # extern crate futures;
|
||||
/// extern crate tokio;
|
||||
///
|
||||
/// use tokio::prelude::*;
|
||||
/// use tokio::sync::watch;
|
||||
///
|
||||
@@ -250,12 +243,12 @@ impl<T> Receiver<T> {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// # extern crate tokio;
|
||||
/// # use tokio::sync::watch;
|
||||
/// use tokio::sync::watch;
|
||||
///
|
||||
/// let (_, rx) = watch::channel("hello");
|
||||
/// assert_eq!(*rx.get_ref(), "hello");
|
||||
/// ```
|
||||
pub fn get_ref(&self) -> Ref<T> {
|
||||
pub fn get_ref(&self) -> Ref<'_, T> {
|
||||
let inner = self.shared.value.read().unwrap();
|
||||
Ref { inner }
|
||||
}
|
||||
@@ -268,7 +261,7 @@ impl<T> Receiver<T> {
|
||||
///
|
||||
/// Only the **most recent** value is returned. If the receiver is falling
|
||||
/// behind the sender, intermediate values are dropped.
|
||||
pub fn poll_ref(&mut self) -> Poll<Option<Ref<T>>, error::RecvError> {
|
||||
pub fn poll_ref(&mut self) -> Poll<Option<Ref<'_, T>>, error::RecvError> {
|
||||
// Make sure the task is up to date
|
||||
self.inner.task.register();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user