mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-15 00:44:33 +00:00
repo_path: rename value() to clearer as_str()
This commit is contained in:
parent
fdeb499836
commit
ac38c8b641
3 changed files with 9 additions and 9 deletions
|
@ -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
|
||||
|
|
|
@ -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<Tree> {
|
||||
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) => {
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue