mirror of
https://github.com/facebook/sapling.git
synced 2024-10-08 07:49:11 +03:00
mononoke/manifest: add Entry::map_leaf
and Entry::map_tree
Summary: It's useful sometimes, like in the next diff. Reviewed By: mitrandir77 Differential Revision: D25422597 fbshipit-source-id: 0ebb5dcc349bbaacac3dddf03f19e5e092042468
This commit is contained in:
parent
0578e28081
commit
c9568598fb
@ -126,6 +126,20 @@ impl<T, L> Entry<T, L> {
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn map_leaf<L2>(self, m: impl FnOnce(L) -> L2) -> Entry<T, L2> {
|
||||
match self {
|
||||
Entry::Tree(tree) => Entry::Tree(tree),
|
||||
Entry::Leaf(leaf) => Entry::Leaf(m(leaf)),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn map_tree<T2>(self, m: impl FnOnce(T) -> T2) -> Entry<T2, L> {
|
||||
match self {
|
||||
Entry::Tree(tree) => Entry::Tree(m(tree)),
|
||||
Entry::Leaf(leaf) => Entry::Leaf(leaf),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
|
Loading…
Reference in New Issue
Block a user