Skip to content

Commit aadc8df

Browse files
Zoybeanbluss
authored andcommitted
implement AsRef<Path> for ArrayString
1 parent b2886dc commit aadc8df

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/array_string.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use std::fmt;
55
use std::hash::{Hash, Hasher};
66
use std::mem::MaybeUninit;
77
use std::ops::{Deref, DerefMut};
8+
use std::path::Path;
89
use std::ptr;
910
use std::slice;
1011
use std::str;
@@ -501,6 +502,12 @@ impl<const CAP: usize> fmt::Debug for ArrayString<CAP>
501502
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { (**self).fmt(f) }
502503
}
503504

505+
impl<const CAP: usize> AsRef<Path> for ArrayString<CAP> {
506+
fn as_ref(&self) -> &Path {
507+
self.as_str().as_ref()
508+
}
509+
}
510+
504511
impl<const CAP: usize> fmt::Display for ArrayString<CAP>
505512
{
506513
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { (**self).fmt(f) }

0 commit comments

Comments
 (0)