1
Fork 0
mirror of https://github.com/RGBCube/embd-rs synced 2025-07-27 13:37: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 {
/// Returns the absolute path of the entry.
pub fn path(&self) -> &Path {
pub fn path(&self) -> &Cow<'_, str> {
match self {
DirEntry::File(file) => file.path(),
DirEntry::Dir(dir) => dir.path(),
@ -104,13 +104,13 @@ pub struct Dir {
impl Dir {
/// Returns the children of the directory.
pub fn children(&self) -> &'static [DirEntry] {
pub fn children(&self) -> &Cow<'_, [DirEntry]> {
&self.__children
}
/// Returns the absolute path of the directory.
pub fn path(&self) -> &'static Path {
Path::new(self.__path.as_ref().into())
pub fn path(&self) -> &Cow<'_, str> {
&self.__path
}
/// Collects all files from the directory into a vector.
@ -140,13 +140,13 @@ pub struct File {
impl File {
/// Returns the content of the file.
pub fn content(&self) -> &'static [u8] {
pub fn content(&self) -> &Cow<'_, [u8]> {
&self.__content
}
/// Returns the absolute path of the file.
pub fn path(&self) -> &'static Path {
Path::new(self.__path.as_ref().into())
pub fn path(&self) -> &Cow<'_, str> {
&self.__path
}
}