Skip to content

Commit

Permalink
Remove unnecessary Send + Sync bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
jplatte committed Oct 13, 2024
1 parent e4fd1f5 commit e218ce8
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 21 deletions.
14 changes: 7 additions & 7 deletions eyeball-im-util/src/vector/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ pub trait VectorDiffContainer:
{
/// The element type of the [`Vector`][imbl::Vector] that diffs are being
/// handled for.
type Element: Clone + Send + Sync + 'static;
type Element: Clone + 'static;

#[doc(hidden)]
type Family: VectorDiffContainerFamily<Member<Self::Element> = Self>;
}

impl<T: Clone + Send + Sync + 'static> VectorDiffContainer for VectorDiff<T> {
impl<T: Clone + 'static> VectorDiffContainer for VectorDiff<T> {
type Element = T;
type Family = VectorDiffFamily;
}

impl<T: Clone + Send + Sync + 'static> VectorDiffContainer for Vec<VectorDiff<T>> {
impl<T: Clone + 'static> VectorDiffContainer for Vec<VectorDiff<T>> {
type Element = T;
type Family = VecVectorDiffFamily;
}
Expand Down Expand Up @@ -69,15 +69,15 @@ pub trait VectorObserver<T>: Sized {
fn into_parts(self) -> (Vector<T>, Self::Stream);
}

impl<T: Clone + Send + Sync + 'static> VectorObserver<T> for VectorSubscriber<T> {
impl<T: Clone + 'static> VectorObserver<T> for VectorSubscriber<T> {
type Stream = VectorSubscriberStream<T>;

fn into_parts(self) -> (Vector<T>, Self::Stream) {
self.into_values_and_stream()
}
}

impl<T: Clone + Send + Sync + 'static> VectorObserver<T> for BatchedVectorSubscriber<T> {
impl<T: Clone + 'static> VectorObserver<T> for BatchedVectorSubscriber<T> {
type Stream = VectorSubscriberBatchedStream<T>;

fn into_parts(self) -> (Vector<T>, Self::Stream) {
Expand All @@ -102,7 +102,7 @@ where
/// See that trait for which types implement this.
pub trait VectorObserverExt<T>: VectorObserver<T>
where
T: Clone + Send + Sync + 'static,
T: Clone + 'static,
<Self::Stream as Stream>::Item: VectorDiffContainer<Element = T>,
{
/// Filter the vector's values with the given function.
Expand Down Expand Up @@ -197,7 +197,7 @@ where

impl<T, O> VectorObserverExt<T> for O
where
T: Clone + Send + Sync + 'static,
T: Clone + 'static,
O: VectorObserver<T>,
<Self::Stream as Stream>::Item: VectorDiffContainer<Element = T>,
{
Expand Down
6 changes: 3 additions & 3 deletions eyeball-im/src/vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub struct ObservableVector<T> {
sender: Sender<BroadcastMessage<T>>,
}

impl<T: Clone + Send + Sync + 'static> ObservableVector<T> {
impl<T: Clone + 'static> ObservableVector<T> {
/// Create a new `ObservableVector`.
///
/// As of the time of writing, this is equivalent to
Expand Down Expand Up @@ -290,7 +290,7 @@ impl<T: Clone + Send + Sync + 'static> ObservableVector<T> {
}
}

impl<T: Clone + Send + Sync + 'static> Default for ObservableVector<T> {
impl<T: Clone + 'static> Default for ObservableVector<T> {
fn default() -> Self {
Self::new()
}
Expand All @@ -315,7 +315,7 @@ impl<T> ops::Deref for ObservableVector<T> {
}
}

impl<T: Clone + Send + Sync + 'static> From<Vector<T>> for ObservableVector<T> {
impl<T: Clone + 'static> From<Vector<T>> for ObservableVector<T> {
fn from(values: Vector<T>) -> Self {
let mut this = Self::new();
this.append(values);
Expand Down
4 changes: 2 additions & 2 deletions eyeball-im/src/vector/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub struct ObservableVectorEntry<'a, T> {

impl<'a, T> ObservableVectorEntry<'a, T>
where
T: Clone + Send + Sync + 'static,
T: Clone + 'static,
{
pub(super) fn new(inner: &'a mut ObservableVector<T>, index: usize) -> Self {
Self { inner, index: EntryIndex::Owned(index) }
Expand Down Expand Up @@ -115,7 +115,7 @@ pub struct ObservableVectorEntries<'a, T> {

impl<'a, T> ObservableVectorEntries<'a, T>
where
T: Clone + Send + Sync + 'static,
T: Clone + 'static,
{
pub(super) fn new(inner: &'a mut ObservableVector<T>) -> Self {
Self { inner, index: 0 }
Expand Down
10 changes: 4 additions & 6 deletions eyeball-im/src/vector/subscriber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub struct VectorSubscriber<T> {
rx: Receiver<BroadcastMessage<T>>,
}

impl<T: Clone + Send + Sync + 'static> VectorSubscriber<T> {
impl<T: Clone + 'static> VectorSubscriber<T> {
pub(super) fn new(items: Vector<T>, rx: Receiver<BroadcastMessage<T>>) -> Self {
Self { values: items, rx }
}
Expand Down Expand Up @@ -99,7 +99,7 @@ enum VectorSubscriberStreamState<T> {
// Not clear why this explicit impl is needed, but it's not unsafe so it is fine
impl<T> Unpin for VectorSubscriberStreamState<T> {}

impl<T: Clone + Send + Sync + 'static> Stream for VectorSubscriberStream<T> {
impl<T: Clone + 'static> Stream for VectorSubscriberStream<T> {
type Item = VectorDiff<T>;

fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
Expand Down Expand Up @@ -170,7 +170,7 @@ impl<T> VectorSubscriberBatchedStream<T> {
}
}

impl<T: Clone + Send + Sync + 'static> Stream for VectorSubscriberBatchedStream<T> {
impl<T: Clone + 'static> Stream for VectorSubscriberBatchedStream<T> {
type Item = Vec<VectorDiff<T>>;

fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
Expand Down Expand Up @@ -212,9 +212,7 @@ impl<T: Clone + Send + Sync + 'static> Stream for VectorSubscriberBatchedStream<
}
}

fn handle_lag<T: Clone + Send + Sync + 'static>(
rx: &mut Receiver<BroadcastMessage<T>>,
) -> Option<Vector<T>> {
fn handle_lag<T: Clone + 'static>(rx: &mut Receiver<BroadcastMessage<T>>) -> Option<Vector<T>> {
let mut msg = None;
loop {
match rx.try_recv() {
Expand Down
6 changes: 3 additions & 3 deletions eyeball-im/src/vector/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub struct ObservableVectorTransaction<'o, T: Clone> {
batch: Vec<VectorDiff<T>>,
}

impl<'o, T: Clone + Send + Sync + 'static> ObservableVectorTransaction<'o, T> {
impl<'o, T: Clone + 'static> ObservableVectorTransaction<'o, T> {
pub(super) fn new(inner: &'o mut ObservableVector<T>) -> Self {
let values = inner.values.clone();
Self { inner, values, batch: Vec::new() }
Expand Down Expand Up @@ -316,7 +316,7 @@ pub struct ObservableVectorTransactionEntry<'a, 'o, T: Clone> {

impl<'a, 'o, T> ObservableVectorTransactionEntry<'a, 'o, T>
where
T: Clone + Send + Sync + 'static,
T: Clone + 'static,
{
pub(super) fn new(inner: &'a mut ObservableVectorTransaction<'o, T>, index: usize) -> Self {
Self { inner, index: EntryIndex::Owned(index) }
Expand Down Expand Up @@ -397,7 +397,7 @@ pub struct ObservableVectorTransactionEntries<'a, 'o, T: Clone> {

impl<'a, 'o, T> ObservableVectorTransactionEntries<'a, 'o, T>
where
T: Clone + Send + Sync + 'static,
T: Clone + 'static,
{
pub(super) fn new(inner: &'a mut ObservableVectorTransaction<'o, T>) -> Self {
Self { inner, index: 0 }
Expand Down

0 comments on commit e218ce8

Please sign in to comment.