make asset lookup generic over impl Into<&str>

This commit is contained in:
Aravinth Manivannan 2021-09-17 12:59:02 +05:30
parent 4435a569db
commit 978d99b084
Signed by: realaravinth
GPG key ID: AD9F0F08E855ED88
2 changed files with 7 additions and 4 deletions

View file

@ -21,6 +21,9 @@
is unset(i.e `None`), no mime based filtering is done and all files
inside source directory is considered for processing.
- `Files::get_full_path()` and `Files::get()` now accept `impl
Into<&str>` for path argument.
### Fixed:
- `Files::get()` now behaves as it is described in the documentation

View file

@ -40,8 +40,8 @@ impl Files {
///
/// 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].
pub fn get<'a>(&'a self, path: &'a str) -> Option<&'a str> {
if let Some(path) = self.map.get(path) {
pub fn get<'a, 'b>(&'b self, path: impl Into<&'a str>) -> Option<&'b str> {
if let Some(path) = self.map.get(path.into()) {
Some(&path[self.base_dir.len()..])
// Some(&path)
} else {
@ -53,8 +53,8 @@ impl Files {
///
/// If the modified filename path is `./prod/test.randomhash.svg`, it will
/// 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> {
self.map.get(path)
pub fn get_full_path<'a, 'b>(&'b self, path: impl Into<&'a str>) -> Option<&'b String> {
self.map.get(path.into())
}
}