Skip to content

Commit 945d330

Browse files
committed
impl fmt::Display for BorrowedValue<str>
Signed-off-by: snowapril <[email protected]>
1 parent caec579 commit 945d330

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

common/src/borrow.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ use crate::lock::{
22
MapImmutable, PyImmutableMappedMutexGuard, PyMappedMutexGuard, PyMappedRwLockReadGuard,
33
PyMappedRwLockWriteGuard, PyMutexGuard, PyRwLockReadGuard, PyRwLockWriteGuard,
44
};
5-
use std::ops::{Deref, DerefMut};
5+
use std::{
6+
fmt,
7+
ops::{Deref, DerefMut},
8+
};
69

710
macro_rules! impl_from {
811
($lt:lifetime, $gen:ident, $t:ty, $($var:ident($from:ty),)*) => {
@@ -64,6 +67,12 @@ impl<T: ?Sized> Deref for BorrowedValue<'_, T> {
6467
}
6568
}
6669

70+
impl fmt::Display for BorrowedValue<'_, str> {
71+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
72+
fmt::Display::fmt(self.deref(), f)
73+
}
74+
}
75+
6776
#[derive(Debug)]
6877
pub enum BorrowedValueMut<'a, T: ?Sized> {
6978
RefMut(&'a mut T),

0 commit comments

Comments
 (0)