Skip to content

Commit

Permalink
add Index and IndexMut traits to PeerList trait
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxime2 committed Aug 12, 2019
1 parent 2253536 commit 4650cf7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/peer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use core::slice::{Iter, IterMut};
use serde::de::DeserializeOwned;
use serde::Serialize;
use std::fmt::Debug;
use std::ops::{Index, IndexMut};

pub trait PeerId: Eq + Ord + Clone + Debug + Send + Serialize + DeserializeOwned + Sync {}
impl<N> PeerId for N where N: Eq + Ord + Clone + Debug + Send + Serialize + DeserializeOwned + Sync {}
Expand All @@ -22,7 +23,7 @@ pub trait Peer<Id: PeerId> {
fn get_net_addr(&self) -> String;
}

pub trait PeerList<Id: PeerId, Error> {
pub trait PeerList<Id: PeerId, Error>: Index<usize> + IndexMut<usize> {
type P: Peer<Id>;
fn new() -> Self;
fn add(&mut self, peer: Self::P) -> std::result::Result<(), Error>;
Expand Down

0 comments on commit 4650cf7

Please sign in to comment.