Commit ea03cc40 authored by Ian Jackson's avatar Ian Jackson
Browse files

Replace manual Clone impl with educe in tor-rtcompat

parent 9dca756e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -3492,6 +3492,7 @@ dependencies = [
 "async-std",
 "async-trait",
 "async_executors",
 "educe",
 "futures",
 "native-tls",
 "pin-project",
+1 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ rustls = [ "rustls-crate", "async-rustls", "x509-signature" ]

async_executors = { version = "0.4", default_features = false }
async-trait = "0.1.2"
educe = "0.4.6"
futures = "0.3.14"
pin-project = "1"
native-tls-crate = { package = "native-tls", version = "0.2", optional = true }
+3 −10
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ use std::{net::SocketAddr, sync::Arc, time::Duration};

use crate::traits::*;
use async_trait::async_trait;
use educe::Educe;
use futures::{future::FutureObj, task::Spawn};
use std::io::Result as IoResult;

@@ -18,6 +19,8 @@ use std::io::Result as IoResult;
/// You can use this structure to create new runtimes in two ways: either by
/// overriding a single part of an existing runtime, or by building an entirely
/// new runtime from pieces.
#[derive(Educe)]
#[educe(Clone)] // #[derive(Clone)] wrongly infers Clone bounds on the generic parameters
pub struct CompoundRuntime<SpawnR, SleepR, TcpR, TlsR> {
    /// The actual collection of Runtime objects.
    ///
@@ -26,16 +29,6 @@ pub struct CompoundRuntime<SpawnR, SleepR, TcpR, TlsR> {
    inner: Arc<Inner<SpawnR, SleepR, TcpR, TlsR>>,
}

// We have to provide this ourselves, since derive(Clone) wrongly infers a
// `where S: Clone` bound (from the generic argument).
impl<SpawnR, SleepR, TcpR, TlsR> Clone for CompoundRuntime<SpawnR, SleepR, TcpR, TlsR> {
    fn clone(&self) -> Self {
        Self {
            inner: Arc::clone(&self.inner),
        }
    }
}

/// A collection of objects implementing that traits that make up a [`Runtime`]
struct Inner<SpawnR, SleepR, TcpR, TlsR> {
    /// A `Spawn` and `BlockOn` implementation.