From 4c4318116505d42d640042376749e29fa629bd6f Mon Sep 17 00:00:00 2001 From: Tomasz Kurcz Date: Wed, 8 May 2024 17:00:27 +0200 Subject: [PATCH] refactor: less awkward associated type names --- packages/storey/src/containers/column.rs | 8 +++--- packages/storey/src/containers/item.rs | 2 +- packages/storey/src/containers/map.rs | 12 ++++----- packages/storey/src/containers/mod.rs | 34 ++++++++++++------------ 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/packages/storey/src/containers/column.rs b/packages/storey/src/containers/column.rs index 22e97d3..fcd7a2f 100644 --- a/packages/storey/src/containers/column.rs +++ b/packages/storey/src/containers/column.rs @@ -85,7 +85,7 @@ where E: Encoding, T: EncodableWith + DecodableWith, { - type AccessorT = ColumnAccess; + type Accessor = ColumnAccess; type Key = u32; type KeyDecodeError = ColumnKeyDecodeError; type Value = T; @@ -127,10 +127,10 @@ where T: EncodableWith + DecodableWith, S: IterableStorage, { - type StorableT = Column; - type StorageT = S; + type Storable = Column; + type Storage = S; - fn storage(&self) -> &Self::StorageT { + fn storage(&self) -> &Self::Storage { &self.storage } } diff --git a/packages/storey/src/containers/item.rs b/packages/storey/src/containers/item.rs index e7056fc..b9a7f6a 100644 --- a/packages/storey/src/containers/item.rs +++ b/packages/storey/src/containers/item.rs @@ -70,7 +70,7 @@ where E: Encoding, T: EncodableWith + DecodableWith, { - type AccessorT = ItemAccess; + type Accessor = ItemAccess; type Key = (); type KeyDecodeError = ItemKeyDecodeError; type Value = T; diff --git a/packages/storey/src/containers/map.rs b/packages/storey/src/containers/map.rs index d72c0ac..39c46ab 100644 --- a/packages/storey/src/containers/map.rs +++ b/packages/storey/src/containers/map.rs @@ -95,7 +95,7 @@ where V: Storable, ::KeyDecodeError: std::fmt::Display, { - type AccessorT = MapAccess; + type Accessor = MapAccess; type Key = (K, V::Key); type KeyDecodeError = MapKeyDecodeError; type Value = V::Value; @@ -183,7 +183,7 @@ where /// /// assert_eq!(access.entry("foo").entry("bar").get().unwrap(), None); /// ``` - pub fn entry(&self, key: &Q) -> V::AccessorT> + pub fn entry(&self, key: &Q) -> V::Accessor> where K: Borrow, Q: Key + ?Sized, @@ -222,7 +222,7 @@ where /// access.entry_mut("foo").entry_mut("bar").set(&1337).unwrap(); /// assert_eq!(access.entry("foo").entry("bar").get().unwrap(), Some(1337)); /// ``` - pub fn entry_mut(&mut self, key: &Q) -> V::AccessorT> + pub fn entry_mut(&mut self, key: &Q) -> V::Accessor> where K: Borrow, Q: Key + ?Sized, @@ -256,10 +256,10 @@ where ::KeyDecodeError: std::fmt::Display, S: IterableStorage, { - type StorableT = Map; - type StorageT = S; + type Storable = Map; + type Storage = S; - fn storage(&self) -> &Self::StorageT { + fn storage(&self) -> &Self::Storage { &self.storage } } diff --git a/packages/storey/src/containers/mod.rs b/packages/storey/src/containers/mod.rs index d62d40e..3d723d2 100644 --- a/packages/storey/src/containers/mod.rs +++ b/packages/storey/src/containers/mod.rs @@ -20,7 +20,7 @@ pub trait Storable { /// specific [`Storage`] type used (the `S` type parameter here). /// /// [`Storage`]: crate::storage::Storage - type AccessorT; + type Accessor; /// The Key type for this collection/container. This is the type that will be used in /// key iteration. @@ -44,7 +44,7 @@ pub trait Storable { /// Create an accessor for this collection/container, given a [`Storage`] implementation. /// /// [`Storage`]: crate::storage::Storage - fn access_impl(storage: S) -> Self::AccessorT; + fn access_impl(storage: S) -> Self::Accessor; /// Decode a key from a byte slice. /// @@ -70,18 +70,18 @@ pub enum KVDecodeError { /// their contents. pub trait IterableAccessor: Sized { /// The [`Storable`] type this accessor is associated with. - type StorableT: Storable; + type Storable: Storable; /// The [`Storage`] type this accessor is associated with. /// /// [`Storage`]: crate::storage::Storage - type StorageT: IterableStorage; + type Storage: IterableStorage; /// Get a reference to the storage this accessor is associated with. - fn storage(&self) -> &Self::StorageT; + fn storage(&self) -> &Self::Storage; /// Iterate over key-value pairs in this collection. - fn pairs(&self) -> StorableIter<'_, Self::StorableT, Self::StorageT> { + fn pairs(&self) -> StorableIter<'_, Self::Storable, Self::Storage> { StorableIter { inner: self.storage().pairs(None, None), phantom: PhantomData, @@ -89,7 +89,7 @@ pub trait IterableAccessor: Sized { } /// Iterate over keys in this collection. - fn keys(&self) -> StorableKeys<'_, Self::StorableT, Self::StorageT> { + fn keys(&self) -> StorableKeys<'_, Self::Storable, Self::Storage> { StorableKeys { inner: self.storage().keys(None, None), phantom: PhantomData, @@ -97,7 +97,7 @@ pub trait IterableAccessor: Sized { } /// Iterate over values in this collection. - fn values(&self) -> StorableValues<'_, Self::StorableT, Self::StorageT> { + fn values(&self) -> StorableValues<'_, Self::Storable, Self::Storage> { StorableValues { inner: self.storage().values(None, None), phantom: PhantomData, @@ -111,10 +111,10 @@ pub trait BoundedIterableAccessor: IterableAccessor { &self, start: Option, end: Option, - ) -> StorableIter<'_, Self::StorableT, Self::StorageT> + ) -> StorableIter<'_, Self::Storable, Self::Storage> where - S: BoundFor, - E: BoundFor, + S: BoundFor, + E: BoundFor, { let start = start.map(|b| b.into_bytes()); let end = end.map(|b| b.into_bytes()); @@ -130,10 +130,10 @@ pub trait BoundedIterableAccessor: IterableAccessor { &self, start: Option, end: Option, - ) -> StorableKeys<'_, Self::StorableT, Self::StorageT> + ) -> StorableKeys<'_, Self::Storable, Self::Storage> where - S: BoundFor, - E: BoundFor, + S: BoundFor, + E: BoundFor, { let start = start.map(|b| b.into_bytes()); let end = end.map(|b| b.into_bytes()); @@ -149,10 +149,10 @@ pub trait BoundedIterableAccessor: IterableAccessor { &self, start: Option, end: Option, - ) -> StorableValues<'_, Self::StorableT, Self::StorageT> + ) -> StorableValues<'_, Self::Storable, Self::Storage> where - S: BoundFor, - E: BoundFor, + S: BoundFor, + E: BoundFor, { let start = start.map(|b| b.into_bytes()); let end = end.map(|b| b.into_bytes());