diff options
Diffstat (limited to 'src/collection/guard.rs')
| -rw-r--r-- | src/collection/guard.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/collection/guard.rs b/src/collection/guard.rs index 8857c5f..0b8a583 100644 --- a/src/collection/guard.rs +++ b/src/collection/guard.rs @@ -42,3 +42,19 @@ impl<'key, Guard, Key: Keyable> AsMut<Guard> for LockGuard<'key, Guard, Key> { &mut self.guard } } + +#[cfg(test)] +mod tests { + use crate::collection::OwnedLockCollection; + use crate::{RwLock, ThreadKey}; + + use super::*; + + #[test] + fn guard_display_works() { + let key = ThreadKey::get().unwrap(); + let lock = OwnedLockCollection::new(RwLock::new("Hello, world!")); + let guard = lock.read(key); + assert_eq!(guard.to_string(), "Hello, world!".to_string()); + } +} |
