diff options
| author | Linus Färnstrand <linus@mullvad.net> | 2017-06-19 09:32:35 +0200 |
|---|---|---|
| committer | Linus Färnstrand <linus@mullvad.net> | 2017-06-21 03:29:44 +0200 |
| commit | 0639b4b6fdbd16b640dafd39c160db5e342788e9 (patch) | |
| tree | 1abe8dc9cda84449a85bf01147ebf64337e5618a /talpid_core | |
| parent | 22a73df71fc6d028d84b54776d6f5e7c7066da27 (diff) | |
| download | mullvadvpn-0639b4b6fdbd16b640dafd39c160db5e342788e9.tar.xz mullvadvpn-0639b4b6fdbd16b640dafd39c160db5e342788e9.zip | |
Renamed plexmpsc to mpsc and Sender to IntoSender
Diffstat (limited to 'talpid_core')
| -rw-r--r-- | talpid_core/src/lib.rs | 4 | ||||
| -rw-r--r-- | talpid_core/src/mpsc.rs (renamed from talpid_core/src/plexmpsc.rs) | 12 |
2 files changed, 8 insertions, 8 deletions
diff --git a/talpid_core/src/lib.rs b/talpid_core/src/lib.rs index 3ebb24d1ec..52213ebee0 100644 --- a/talpid_core/src/lib.rs +++ b/talpid_core/src/lib.rs @@ -31,5 +31,5 @@ pub mod net; /// Abstracts over different VPN tunnel technologies pub mod tunnel; -/// Multiplexing abstractions over `std::mpsc` -pub mod plexmpsc; +/// Abstractions and extra features on `std::mpsc` +pub mod mpsc; diff --git a/talpid_core/src/plexmpsc.rs b/talpid_core/src/mpsc.rs index be1904bdb2..d63956c452 100644 --- a/talpid_core/src/plexmpsc.rs +++ b/talpid_core/src/mpsc.rs @@ -3,12 +3,12 @@ use std::sync::mpsc; /// Abstraction over an `mpsc::Sender` that first converts the value to another type before sending. #[derive(Debug, Clone)] -pub struct Sender<T, U> { +pub struct IntoSender<T, U> { sender: mpsc::Sender<U>, _marker: PhantomData<T>, } -impl<T, U> Sender<T, U> +impl<T, U> IntoSender<T, U> where T: Into<U> { /// Converts the `T` into a `U` and sends it on the channel. @@ -17,11 +17,11 @@ impl<T, U> Sender<T, U> } } -impl<T, U> From<mpsc::Sender<U>> for Sender<T, U> +impl<T, U> From<mpsc::Sender<U>> for IntoSender<T, U> where T: Into<U> { fn from(sender: mpsc::Sender<U>) -> Self { - Sender { + IntoSender { sender: sender, _marker: PhantomData, } @@ -55,7 +55,7 @@ mod tests { #[test] fn sender() { let (tx, rx) = mpsc::channel::<Outer>(); - let inner_tx: Sender<Inner, Outer> = tx.clone().into(); + let inner_tx: IntoSender<Inner, Outer> = tx.clone().into(); tx.send(Outer::Other).unwrap(); inner_tx.send(Inner::Two).unwrap(); @@ -67,7 +67,7 @@ mod tests { #[test] fn send_between_thread() { let (tx, rx) = mpsc::channel::<Outer>(); - let inner_tx: Sender<Inner, Outer> = tx.clone().into(); + let inner_tx: IntoSender<Inner, Outer> = tx.clone().into(); thread::spawn(move || { inner_tx.send(Inner::One).unwrap(); }); |
