From ac38c8b64157c246f807bc2f267d18dc908e3b0c Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Sat, 5 Jun 2021 22:48:09 -0700 Subject: [PATCH] repo_path: rename value() to clearer as_str() --- lib/src/repo_path.rs | 4 ++-- lib/src/tree.rs | 6 +++--- lib/src/tree_builder.rs | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/src/repo_path.rs b/lib/src/repo_path.rs index e8fec6c0b..3e7d6fc72 100644 --- a/lib/src/repo_path.rs +++ b/lib/src/repo_path.rs @@ -21,7 +21,7 @@ pub struct RepoPathComponent { } impl RepoPathComponent { - pub fn value(&self) -> &str { + pub fn as_str(&self) -> &str { &self.value } } @@ -73,7 +73,7 @@ impl RepoPath { pub fn to_internal_dir_string(&self) -> String { let mut result = String::new(); for component in &self.components { - result.push_str(component.value()); + result.push_str(component.as_str()); result.push('/'); } result diff --git a/lib/src/tree.rs b/lib/src/tree.rs index ec4f08346..ff2130440 100644 --- a/lib/src/tree.rs +++ b/lib/src/tree.rs @@ -126,14 +126,14 @@ impl Tree { match path.split() { Some((dir, basename)) => self .sub_tree_recursive(dir.components()) - .and_then(|tree| tree.data.value(basename.value()).cloned()), + .and_then(|tree| tree.data.value(basename.as_str()).cloned()), None => Some(TreeValue::Tree(self.id.clone())), } } pub fn sub_tree(&self, name: &RepoPathComponent) -> Option { self.data - .value(name.value()) + .value(name.as_str()) .and_then(|sub_tree| match sub_tree { TreeValue::Tree(sub_tree_id) => { let subdir = self.dir.join(name); @@ -160,7 +160,7 @@ impl Tree { data: self.data.clone(), }) } else { - match self.data.entry(components[0].value()) { + match self.data.entry(components[0].as_str()) { None => None, Some(entry) => match entry.value() { TreeValue::Tree(sub_tree_id) => { diff --git a/lib/src/tree_builder.rs b/lib/src/tree_builder.rs index fe281f1e6..24f78cdf7 100644 --- a/lib/src/tree_builder.rs +++ b/lib/src/tree_builder.rs @@ -68,10 +68,10 @@ impl TreeBuilder { let tree = trees_to_write.get_mut(&dir).unwrap(); match file_override { Override::Replace(value) => { - tree.set(basename.value().to_string(), value); + tree.set(basename.as_str().to_string(), value); } Override::Tombstone => { - tree.remove(basename.value()); + tree.remove(basename.as_str()); } } } @@ -95,10 +95,10 @@ impl TreeBuilder { if let Some((parent, basename)) = dir.split() { let parent_tree = trees_to_write.get_mut(&parent).unwrap(); if tree.is_empty() { - parent_tree.remove(basename.value()); + parent_tree.remove(basename.as_str()); } else { let tree_id = store.write_tree(&dir, &tree).unwrap(); - parent_tree.set(basename.value().to_string(), TreeValue::Tree(tree_id)); + parent_tree.set(basename.as_str().to_string(), TreeValue::Tree(tree_id)); } } else { // We're writing the root tree. Write it even if empty. Return its id.