From ebbe3cfce28914d776f3e5f89894fab50911c57e Mon Sep 17 00:00:00 2001 From: Botahamec Date: Wed, 22 May 2024 15:53:49 -0400 Subject: Implemented necessary traits --- src/collection/owned.rs | 50 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'src/collection/owned.rs') diff --git a/src/collection/owned.rs b/src/collection/owned.rs index 3415ac4..eb5e03a 100644 --- a/src/collection/owned.rs +++ b/src/collection/owned.rs @@ -32,12 +32,62 @@ unsafe impl Sharable for OwnedLockCollection {} unsafe impl OwnedLockable for OwnedLockCollection {} +impl IntoIterator for OwnedLockCollection +where + L: IntoIterator, +{ + type Item = ::Item; + type IntoIter = ::IntoIter; + + fn into_iter(self) -> Self::IntoIter { + self.data.into_iter() + } +} + +impl + OwnedLockable> FromIterator + for OwnedLockCollection +{ + fn from_iter>(iter: T) -> Self { + let iter: I = iter.into_iter().collect(); + Self::new(iter) + } +} + +impl, L: OwnedLockable> Extend for OwnedLockCollection { + fn extend>(&mut self, iter: T) { + self.data.extend(iter) + } +} + +impl AsMut for OwnedLockCollection { + fn as_mut(&mut self) -> &mut L { + &mut self.data + } +} + +impl Default for OwnedLockCollection { + fn default() -> Self { + Self::new(L::default()) + } +} + +impl From for OwnedLockCollection { + fn from(value: L) -> Self { + Self::new(value) + } +} + impl OwnedLockCollection { #[must_use] pub const fn new(data: L) -> Self { Self { data } } + #[must_use] + pub fn into_inner(self) -> L { + self.data + } + pub fn lock<'g, 'key, Key: Keyable + 'key>( &'g self, key: Key, -- cgit v1.2.3