implement AsRef<Path> for ArrayString

This commit is contained in:
Zoey Llewellyn Hewll
2023-11-16 15:56:04 +08:00
committed by bluss
parent b2886dcec0
commit aadc8df8c7
+7
View File
@@ -5,6 +5,7 @@ use std::fmt;
use std::hash::{Hash, Hasher};
use std::mem::MaybeUninit;
use std::ops::{Deref, DerefMut};
use std::path::Path;
use std::ptr;
use std::slice;
use std::str;
@@ -501,6 +502,12 @@ impl<const CAP: usize> fmt::Debug for ArrayString<CAP>
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { (**self).fmt(f) }
}
impl<const CAP: usize> AsRef<Path> for ArrayString<CAP> {
fn as_ref(&self) -> &Path {
self.as_str().as_ref()
}
}
impl<const CAP: usize> fmt::Display for ArrayString<CAP>
{
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { (**self).fmt(f) }