From d86f7ca905c201cecd4028e9a9364bdc6b9f4fb8 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Thu, 16 Mar 2023 11:20:52 +0100 Subject: [PATCH] eyeball-im: Switch to imbl --- eyeball-im/CHANGELOG.md | 3 +++ eyeball-im/Cargo.toml | 2 +- eyeball-im/src/vector.rs | 17 ++++++++--------- eyeball-im/tests/it.rs | 2 +- 4 files changed, 13 insertions(+), 11 deletions(-) create mode 100644 eyeball-im/CHANGELOG.md diff --git a/eyeball-im/CHANGELOG.md b/eyeball-im/CHANGELOG.md new file mode 100644 index 0000000..4687f24 --- /dev/null +++ b/eyeball-im/CHANGELOG.md @@ -0,0 +1,3 @@ +# unreleased + +- Switch from the unmaintained `im` crate to the maintained fork `imbl` diff --git a/eyeball-im/Cargo.toml b/eyeball-im/Cargo.toml index fed2701..ffd34ae 100644 --- a/eyeball-im/Cargo.toml +++ b/eyeball-im/Cargo.toml @@ -11,7 +11,7 @@ all-features = true [dependencies] futures-core.workspace = true -im = "15.1.0" +imbl = "2.0.0" tokio.workspace = true tokio-stream.workspace = true tracing = { workspace = true, optional = true } diff --git a/eyeball-im/src/vector.rs b/eyeball-im/src/vector.rs index b3593dd..33538c6 100644 --- a/eyeball-im/src/vector.rs +++ b/eyeball-im/src/vector.rs @@ -5,12 +5,12 @@ use std::{ }; use futures_core::Stream; -use im::Vector; +use imbl::Vector; use tokio::sync::broadcast::{self, Sender}; use tokio_stream::wrappers::{errors::BroadcastStreamRecvError, BroadcastStream}; /// An ordered list of elements that broadcasts any changes made to it. -pub struct ObservableVector { +pub struct ObservableVector { values: Vector, sender: Sender>, } @@ -180,7 +180,7 @@ impl Default for ObservableVector { impl fmt::Debug for ObservableVector where - T: Clone + fmt::Debug, + T: fmt::Debug, { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("ObservableVector").field("values", &self.values).finish_non_exhaustive() @@ -189,7 +189,7 @@ where // Note: No DerefMut because all mutating must go through inherent methods that // notify subscribers -impl ops::Deref for ObservableVector { +impl ops::Deref for ObservableVector { type Target = Vector; fn deref(&self) -> &Self::Target { @@ -206,7 +206,7 @@ impl From> for ObservableVector { } #[derive(Clone)] -struct BroadcastMessage { +struct BroadcastMessage { diff: VectorDiff, state: Vector, } @@ -217,12 +217,12 @@ struct BroadcastMessage { /// other futures-related crates have extension traits with convenience /// methods). #[derive(Debug)] -pub struct VectorSubscriber { +pub struct VectorSubscriber { inner: BroadcastStream>, must_reset: bool, } -impl VectorSubscriber { +impl VectorSubscriber { const fn new(inner: BroadcastStream>) -> Self { Self { inner, must_reset: false } } @@ -258,8 +258,7 @@ impl Stream for VectorSubscriber { /// A change to an [`ObservableVector`]. #[derive(Clone, Debug, PartialEq, Eq)] -// FIXME: Clone bound currently needed for derived `impl Debug for Vector` -pub enum VectorDiff { +pub enum VectorDiff { /// Multiple elements were appended. Append { /// The appended elements. diff --git a/eyeball-im/tests/it.rs b/eyeball-im/tests/it.rs index d78304c..781183b 100644 --- a/eyeball-im/tests/it.rs +++ b/eyeball-im/tests/it.rs @@ -1,4 +1,4 @@ -use im::Vector; +use imbl::Vector; use tokio_stream::StreamExt as _; use eyeball_im::{ObservableVector, VectorDiff};