Simplify snapshot code using match_file_name utility

This commit is contained in:
Lucien Greathouse
2019-10-09 18:27:52 -07:00
parent 6b620ddcef
commit e46f9fd94f
6 changed files with 27 additions and 104 deletions

View File

@@ -12,6 +12,7 @@ use super::{
dir::SnapshotDir,
meta_file::AdjacentMetadata,
middleware::{SnapshotFileResult, SnapshotInstanceResult, SnapshotMiddleware},
util::match_trailing,
};
pub struct SnapshotLua;
@@ -146,15 +147,6 @@ fn snapshot_init<F: ImfsFetcher>(
Ok(None)
}
fn match_trailing<'a>(input: &'a str, trailer: &str) -> Option<&'a str> {
if input.ends_with(trailer) {
let end = input.len().saturating_sub(trailer.len());
Some(&input[..end])
} else {
None
}
}
#[cfg(test)]
mod test {
use super::*;