Skip to content

Commit

Permalink
revset: add EagerRevset::empty() constructor for convenience
Browse files Browse the repository at this point in the history
  • Loading branch information
yuja committed Nov 7, 2022
1 parent 46fe079 commit ed14292
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/src/revset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1152,6 +1152,14 @@ struct EagerRevset<'repo> {
index_entries: Vec<IndexEntry<'repo>>,
}

impl EagerRevset<'static> {
pub const fn empty() -> Self {
EagerRevset {
index_entries: Vec::new(),
}
}
}

impl<'repo> Revset<'repo> for EagerRevset<'repo> {
fn iter<'revset>(&'revset self) -> RevsetIterator<'revset, 'repo> {
RevsetIterator::new(Box::new(self.index_entries.iter().cloned()))
Expand Down Expand Up @@ -1403,9 +1411,7 @@ pub fn evaluate_expression<'repo>(
workspace_ctx: Option<&RevsetWorkspaceContext>,
) -> Result<Box<dyn Revset<'repo> + 'repo>, RevsetError> {
match expression {
RevsetExpression::None => Ok(Box::new(EagerRevset {
index_entries: vec![],
})),
RevsetExpression::None => Ok(Box::new(EagerRevset::empty())),
RevsetExpression::All => evaluate_expression(
repo,
&RevsetExpression::visible_heads().ancestors(),
Expand Down

0 comments on commit ed14292

Please sign in to comment.