about summary refs log tree commit diff
diff options
context:
space:
mode:
authoredef <edef@edef.eu>2024-05-01T13·23+0000
committeredef <edef@edef.eu>2024-05-01T13·40+0000
commitf22232533937b157a926af9840777a38e4a21883 (patch)
tree64a2093eabcf93a947a44c0445b0d5decb97bd8a
parent2513120ff5826bfa9c25b5c47810af68fdafcadf (diff)
fix(tvix/castore/path): join, push -> try_{join,push} r/8061
These are fallible methods, so they should be named accordingly.

Change-Id: I6dc271c42989dd6500173488190f65381835d6fe
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11572
Tested-by: BuildkiteCI
Reviewed-by: flokli <flokli@flokli.de>
-rw-r--r--tvix/castore/src/path.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/tvix/castore/src/path.rs b/tvix/castore/src/path.rs
index 34fac5a2f8c0..498f9a91b06a 100644
--- a/tvix/castore/src/path.rs
+++ b/tvix/castore/src/path.rs
@@ -73,10 +73,10 @@ impl Path {
     }
 
     /// Creates a PathBuf with `name` adjoined to self.
-    pub fn join(&self, name: &[u8]) -> Result<PathBuf, std::io::Error> {
+    pub fn try_join(&self, name: &[u8]) -> Result<PathBuf, std::io::Error> {
         let mut v = PathBuf::with_capacity(self.inner.len() + name.len() + 1);
         v.inner.extend_from_slice(&self.inner);
-        v.push(name)?;
+        v.try_push(name)?;
 
         Ok(v)
     }
@@ -204,7 +204,7 @@ impl PathBuf {
     }
 
     /// Adjoins `name` to self.
-    pub fn push(&mut self, name: &[u8]) -> Result<(), std::io::Error> {
+    pub fn try_push(&mut self, name: &[u8]) -> Result<(), std::io::Error> {
         validate_node_name(name).map_err(|_| std::io::ErrorKind::InvalidData)?;
 
         if !self.inner.is_empty() {
@@ -299,8 +299,8 @@ mod test {
     #[case("a", "b", "a/b")]
     #[case("a", "b", "a/b")]
     pub fn join_push(#[case] mut p: PathBuf, #[case] name: &str, #[case] exp_p: PathBuf) {
-        assert_eq!(exp_p, p.join(name.as_bytes()).expect("join failed"));
-        p.push(name.as_bytes()).expect("push failed");
+        assert_eq!(exp_p, p.try_join(name.as_bytes()).expect("join failed"));
+        p.try_push(name.as_bytes()).expect("push failed");
         assert_eq!(exp_p, p);
     }
 
@@ -314,9 +314,9 @@ mod test {
     #[case("", ".")]
     #[case("", "..")]
     pub fn join_push_fail(#[case] mut p: PathBuf, #[case] name: &str) {
-        p.join(name.as_bytes())
+        p.try_join(name.as_bytes())
             .expect_err("join succeeded unexpectedly");
-        p.push(name.as_bytes())
+        p.try_push(name.as_bytes())
             .expect_err("push succeeded unexpectedly");
     }