--- a/rust/hg-core/src/revlog/nodemap_docket.rs Mon Nov 14 15:29:58 2022 +0100
+++ b/rust/hg-core/src/revlog/nodemap_docket.rs Mon Nov 14 15:31:49 2022 +0100
@@ -3,7 +3,6 @@
use memmap2::Mmap;
use std::path::{Path, PathBuf};
-use crate::utils::strip_suffix;
use crate::vfs::Vfs;
const ONDISK_VERSION: u8 = 1;
@@ -97,8 +96,9 @@
.expect("expected a base name")
.to_str()
.expect("expected an ASCII file name in the store");
- let prefix = strip_suffix(docket_name, ".n.a")
- .or_else(|| strip_suffix(docket_name, ".n"))
+ let prefix = docket_name
+ .strip_suffix(".n.a")
+ .or_else(|| docket_name.strip_suffix(".n"))
.expect("expected docket path in .n or .n.a");
let name = format!("{}-{}.nd", prefix, uid);
docket_path
--- a/rust/hg-core/src/utils.rs Mon Nov 14 15:29:58 2022 +0100
+++ b/rust/hg-core/src/utils.rs Mon Nov 14 15:31:49 2022 +0100
@@ -196,15 +196,6 @@
}
}
-// TODO: use the str method when we require Rust 1.45
-pub(crate) fn strip_suffix<'a>(s: &'a str, suffix: &str) -> Option<&'a str> {
- if s.ends_with(suffix) {
- Some(&s[..s.len() - suffix.len()])
- } else {
- None
- }
-}
-
#[cfg(unix)]
pub fn shell_quote(value: &[u8]) -> Vec<u8> {
// TODO: Use the `matches!` macro when we require Rust 1.42+