diff --git a/rust/hg-core/src/revlog/nodemap_docket.rs b/rust/hg-core/src/revlog/nodemap_docket.rs --- a/rust/hg-core/src/revlog/nodemap_docket.rs +++ b/rust/hg-core/src/revlog/nodemap_docket.rs @@ -3,7 +3,6 @@ use bytes_cast::{unaligned, BytesCast}; 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 @@ fn rawdata_path(docket_path: &Path, uid: .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 diff --git a/rust/hg-core/src/utils.rs b/rust/hg-core/src/utils.rs --- a/rust/hg-core/src/utils.rs +++ b/rust/hg-core/src/utils.rs @@ -196,15 +196,6 @@ impl<'a> Escaped for &'a HgPath { } } -// 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 { // TODO: Use the `matches!` macro when we require Rust 1.42+