make asset lookup generic over impl Into<&str>
This commit is contained in:
parent
4435a569db
commit
978d99b084
2 changed files with 7 additions and 4 deletions
|
@ -21,6 +21,9 @@
|
||||||
is unset(i.e `None`), no mime based filtering is done and all files
|
is unset(i.e `None`), no mime based filtering is done and all files
|
||||||
inside source directory is considered for processing.
|
inside source directory is considered for processing.
|
||||||
|
|
||||||
|
- `Files::get_full_path()` and `Files::get()` now accept `impl
|
||||||
|
Into<&str>` for path argument.
|
||||||
|
|
||||||
### Fixed:
|
### Fixed:
|
||||||
|
|
||||||
- `Files::get()` now behaves as it is described in the documentation
|
- `Files::get()` now behaves as it is described in the documentation
|
||||||
|
|
|
@ -40,8 +40,8 @@ impl Files {
|
||||||
///
|
///
|
||||||
/// If the modified filename path is `./prod/test.randomhash.svg`, it will
|
/// If the modified filename path is `./prod/test.randomhash.svg`, it will
|
||||||
/// output `/test.randomhash.svg`. For full path, see [get_full_path][Self::get_full_path].
|
/// output `/test.randomhash.svg`. For full path, see [get_full_path][Self::get_full_path].
|
||||||
pub fn get<'a>(&'a self, path: &'a str) -> Option<&'a str> {
|
pub fn get<'a, 'b>(&'b self, path: impl Into<&'a str>) -> Option<&'b str> {
|
||||||
if let Some(path) = self.map.get(path) {
|
if let Some(path) = self.map.get(path.into()) {
|
||||||
Some(&path[self.base_dir.len()..])
|
Some(&path[self.base_dir.len()..])
|
||||||
// Some(&path)
|
// Some(&path)
|
||||||
} else {
|
} else {
|
||||||
|
@ -53,8 +53,8 @@ impl Files {
|
||||||
///
|
///
|
||||||
/// If the modified filename path is `./prod/test.randomhash.svg`, it will
|
/// If the modified filename path is `./prod/test.randomhash.svg`, it will
|
||||||
/// output `/prod/test.randomhash.svg`. For relative path, see [get][Self::get].
|
/// output `/prod/test.randomhash.svg`. For relative path, see [get][Self::get].
|
||||||
pub fn get_full_path<'a>(&'a self, path: &'a str) -> Option<&'a String> {
|
pub fn get_full_path<'a, 'b>(&'b self, path: impl Into<&'a str>) -> Option<&'b String> {
|
||||||
self.map.get(path)
|
self.map.get(path.into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue