Replace manual Default and new with std derive in tor-proto

This commit is contained in:
Ian Jackson 2022-03-02 17:54:59 +00:00
parent 535e4ff118
commit 89074a1326
2 changed files with 4 additions and 18 deletions

View File

@ -189,6 +189,7 @@ impl Sink<ChanCell> for Channel {
}
/// Structure for building and launching a Tor channel.
#[derive(Default)]
pub struct ChannelBuilder {
/// If present, a description of the address we're trying to connect to,
/// to be used in log messages.
@ -201,7 +202,7 @@ pub struct ChannelBuilder {
impl ChannelBuilder {
/// Construct a new ChannelBuilder.
pub fn new() -> Self {
ChannelBuilder { target: None }
ChannelBuilder::default()
}
/// Set the declared target address of this channel.
@ -228,12 +229,6 @@ impl ChannelBuilder {
}
}
impl Default for ChannelBuilder {
fn default() -> Self {
Self::new()
}
}
impl Channel {
/// Construct a channel and reactor.
///

View File

@ -157,7 +157,7 @@ struct SubprotocolEntry {
/// use tor_protover::Protocols;
/// let p: Result<Protocols,_> = "Link=1-3 LinkAuth=2-3 Relay=1-2".parse();
/// ```
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Default)]
pub struct Protocols {
/// A mapping from protocols' integer encodings to bit-vectors.
recognized: [u64; N_RECOGNIZED],
@ -168,10 +168,7 @@ pub struct Protocols {
impl Protocols {
/// Return a new empty set of protocol versions.
pub fn new() -> Self {
Protocols {
recognized: [0_u64; N_RECOGNIZED],
unrecognized: Vec::new(),
}
Protocols::default()
}
/// Helper: return true iff this protocol set contains the
/// version `ver` of the protocol represented by the integer `proto`.
@ -267,12 +264,6 @@ impl Protocols {
}
}
impl Default for Protocols {
fn default() -> Self {
Protocols::new()
}
}
/// An error representing a failure to parse a set of protocol versions.
#[derive(Error, Debug, PartialEq, Eq, Clone)]
#[non_exhaustive]