From 43ce8968d567ca558614946e84cc4154000c80bc Mon Sep 17 00:00:00 2001 From: Al Liu Date: Sun, 15 Sep 2024 18:57:35 +0800 Subject: [PATCH] Cleanup comment out code --- .codecov.yml | 3 ++- src/swmr.rs | 3 ++- src/swmr/generic.rs | 1 - src/swmr/generic/traits/impls/bytes.rs | 2 +- src/swmr/wal.rs | 19 ++++++++++++------- src/unsync.rs | 12 +++++++++++- 6 files changed, 28 insertions(+), 12 deletions(-) diff --git a/.codecov.yml b/.codecov.yml index 750acffe..78ea96ba 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -5,9 +5,10 @@ ignore: - "**/integration/" - "**/examples/" - "**/benches/" + - "src/tests.rs" + - "src/error.rs" - "src/swmr/generic/traits/impls/" - "src/swmr/generic/traits/impls.rs" - - "src/tests.rs" - "src/swmr/generic/tests.rs" - "src/swmr/generic/tests/" - "src/swmr/wal/tests.rs" diff --git a/src/swmr.rs b/src/swmr.rs index 84a65d38..763bab86 100644 --- a/src/swmr.rs +++ b/src/swmr.rs @@ -1,4 +1,5 @@ -mod wal; +/// The ordered write-ahead log only supports bytes. +pub mod wal; pub use wal::OrderWal; /// The generic implementation of the ordered write-ahead log. diff --git a/src/swmr/generic.rs b/src/swmr/generic.rs index 7d4d0ec2..acd43d3d 100644 --- a/src/swmr/generic.rs +++ b/src/swmr/generic.rs @@ -1498,7 +1498,6 @@ where requested, available, } => error::Error::insufficient_space(requested, available), - ArenaError::ReadOnly => error::Error::read_only(), _ => unreachable!(), }; Err(Among::Right(e)) diff --git a/src/swmr/generic/traits/impls/bytes.rs b/src/swmr/generic/traits/impls/bytes.rs index 34c752fa..779c3e2e 100644 --- a/src/swmr/generic/traits/impls/bytes.rs +++ b/src/swmr/generic/traits/impls/bytes.rs @@ -78,7 +78,7 @@ impl<'a> TypeRef<'a> for &'a [u8] { #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct SliceRef<'a>(&'a [u8]); -impl<'a> Borrow<[u8]> for SliceRef<'a> { +impl Borrow<[u8]> for SliceRef<'_> { fn borrow(&self) -> &[u8] { self.0 } diff --git a/src/swmr/wal.rs b/src/swmr/wal.rs index 86c541d5..1e0c0e92 100644 --- a/src/swmr/wal.rs +++ b/src/swmr/wal.rs @@ -30,6 +30,7 @@ pub use iter::*; ))] mod tests; +#[doc(hidden)] pub struct OrderWalCore { arena: Arena, map: SkipSet>, @@ -146,7 +147,6 @@ where requested, available, } => error::Error::insufficient_space(requested, available), - ArenaError::ReadOnly => error::Error::read_only(), _ => unreachable!(), }; Err(Among::Right(e)) @@ -213,13 +213,18 @@ where } impl OrderWal { - // /// Returns the read-only view for the WAL. - // #[inline] - // pub fn reader(&self) -> OrderWalReader { - // OrderWalReader::new(self.core.clone()) - // } - /// Returns the path of the WAL if it is backed by a file. + /// + /// # Example + /// + /// ```rust + /// use orderwal::{swmr::OrderWal, Wal, Builder}; + /// + /// // A in-memory WAL + /// let wal = OrderWal::new(Builder::new().with_capacity(100)).unwrap(); + /// + /// assert!(wal.path_buf().is_none()); + /// ``` pub fn path_buf(&self) -> Option<&std::sync::Arc> { self.core.arena.path() } diff --git a/src/unsync.rs b/src/unsync.rs index a31e2634..26e102a1 100644 --- a/src/unsync.rs +++ b/src/unsync.rs @@ -74,6 +74,17 @@ where impl OrderWal { /// Returns the path of the WAL if it is backed by a file. + /// + /// # Example + /// + /// ```rust + /// use orderwal::{unsync::OrderWal, Wal, Builder}; + /// + /// // A in-memory WAL + /// let wal = OrderWal::new(Builder::new().with_capacity(100)).unwrap(); + /// + /// assert!(wal.path_buf().is_none()); + /// ``` pub fn path_buf(&self) -> Option<&std::rc::Rc> { self.core().arena.path() } @@ -117,7 +128,6 @@ where requested, available, } => error::Error::insufficient_space(requested, available), - ArenaError::ReadOnly => error::Error::read_only(), _ => unreachable!(), }; Err(Among::Right(e))