Skip to content

Commit

Permalink
fix: relax the lifetime of file contents
Browse files Browse the repository at this point in the history
  • Loading branch information
dsgallups committed Jan 21, 2025
1 parent d742c6f commit afa978d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions include_dir/src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ impl<'a> File<'a> {
}

/// The file's raw contents.
pub fn contents(&self) -> &[u8] {
pub fn contents(&self) -> &'a [u8] {
self.contents
}

/// The file's contents interpreted as a string.
pub fn contents_utf8(&self) -> Option<&str> {
pub fn contents_utf8(&self) -> Option<&'a str> {
std::str::from_utf8(self.contents()).ok()
}
}
Expand Down
2 changes: 1 addition & 1 deletion include_dir/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,6 @@ pub use crate::metadata::Metadata;
pub use crate::{dir::Dir, dir_entry::DirEntry, file::File};
pub use include_dir_macros::include_dir;

#[doc = include_str!("../README.md")]
#[doc = include_str!("../../README.md")]
#[allow(dead_code)]
fn check_readme_examples() {}

0 comments on commit afa978d

Please sign in to comment.