1
Fork 0
mirror of https://github.com/RGBCube/embd-rs synced 2025-07-27 05:27:44 +00:00

Fix lifetime issues

This commit is contained in:
RGBCube 2024-01-05 12:44:30 +03:00
parent e3611073b5
commit 8d060ef70a
No known key found for this signature in database

View file

@ -84,7 +84,7 @@ pub enum DirEntry {
impl DirEntry { impl DirEntry {
/// Returns the absolute path of the entry. /// Returns the absolute path of the entry.
pub fn path(&self) -> &Path { pub fn path(&self) -> &Cow<'_, str> {
match self { match self {
DirEntry::File(file) => file.path(), DirEntry::File(file) => file.path(),
DirEntry::Dir(dir) => dir.path(), DirEntry::Dir(dir) => dir.path(),
@ -104,13 +104,13 @@ pub struct Dir {
impl Dir { impl Dir {
/// Returns the children of the directory. /// Returns the children of the directory.
pub fn children(&self) -> &'static [DirEntry] { pub fn children(&self) -> &Cow<'_, [DirEntry]> {
&self.__children &self.__children
} }
/// Returns the absolute path of the directory. /// Returns the absolute path of the directory.
pub fn path(&self) -> &'static Path { pub fn path(&self) -> &Cow<'_, str> {
Path::new(self.__path.as_ref().into()) &self.__path
} }
/// Collects all files from the directory into a vector. /// Collects all files from the directory into a vector.
@ -140,13 +140,13 @@ pub struct File {
impl File { impl File {
/// Returns the content of the file. /// Returns the content of the file.
pub fn content(&self) -> &'static [u8] { pub fn content(&self) -> &Cow<'_, [u8]> {
&self.__content &self.__content
} }
/// Returns the absolute path of the file. /// Returns the absolute path of the file.
pub fn path(&self) -> &'static Path { pub fn path(&self) -> &Cow<'_, str> {
Path::new(self.__path.as_ref().into()) &self.__path
} }
} }