Skip to content

Commit

Permalink
Elide unnecessary lifetimes in impl
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaskrause committed Dec 30, 2024
1 parent 84d5663 commit 3f8620e
Show file tree
Hide file tree
Showing 25 changed files with 60 additions and 61 deletions.
2 changes: 1 addition & 1 deletion capi/src/cerror.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct CauseIterator<'a> {
current: Option<&'a dyn StdError>,
}

impl<'a> std::iter::Iterator for CauseIterator<'a> {
impl std::iter::Iterator for CauseIterator<'_> {
type Item = Error;

fn next(&mut self) -> std::option::Option<Error> {
Expand Down
2 changes: 1 addition & 1 deletion core/src/dfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ impl<'a> CycleSafeDFS<'a> {
}
}

impl<'a> Iterator for CycleSafeDFS<'a> {
impl Iterator for CycleSafeDFS<'_> {
type Item = Result<DFSStep>;

fn next(&mut self) -> Option<Self::Item> {
Expand Down
2 changes: 1 addition & 1 deletion core/src/graph/storage/union.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl<'a> UnionEdgeContainer<'a> {
}
}

impl<'a> EdgeContainer for UnionEdgeContainer<'a> {
impl EdgeContainer for UnionEdgeContainer<'_> {
fn get_outgoing_edges<'b>(
&'b self,
node: NodeID,
Expand Down
4 changes: 2 additions & 2 deletions core/src/util/disk_collections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ where
}
}

impl<'a, K, V> Iterator for CombinedRange<'a, K, V>
impl<K, V> Iterator for CombinedRange<'_, K, V>
where
K: Ord,
for<'de> K: 'static + Clone + KeySerializer + Send,
Expand Down Expand Up @@ -556,7 +556,7 @@ where
}
}

impl<'a, K, V> FusedIterator for CombinedRange<'a, K, V>
impl<K, V> FusedIterator for CombinedRange<'_, K, V>
where
K: 'static + Ord + Clone + KeySerializer + Serialize + DeserializeOwned + Send,
for<'de> V: 'static + Clone + Serialize + Deserialize<'de> + Send,
Expand Down
8 changes: 4 additions & 4 deletions graphannis/src/annis/db/aql/operators/equal_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub struct EqualValue<'a> {
negated: bool,
}

impl<'a> std::fmt::Display for EqualValue<'a> {
impl std::fmt::Display for EqualValue<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
if self.negated {
write!(f, "!=")
Expand All @@ -75,7 +75,7 @@ impl<'a> std::fmt::Display for EqualValue<'a> {
}
}

impl<'a> EqualValue<'a> {
impl EqualValue<'_> {
fn value_for_match(&self, m: &Match, spec: &NodeSearchSpec) -> Result<Option<Cow<str>>> {
match spec {
NodeSearchSpec::ExactValue { .. }
Expand Down Expand Up @@ -119,7 +119,7 @@ impl<'a> EqualValue<'a> {
}
}

impl<'a> BinaryOperatorBase for EqualValue<'a> {
impl BinaryOperatorBase for EqualValue<'_> {
fn filter_match(&self, lhs: &Match, rhs: &Match) -> Result<bool> {
let lhs_val = self.value_for_match(lhs, &self.spec_left)?;
let rhs_val = self.value_for_match(rhs, &self.spec_right)?;
Expand Down Expand Up @@ -177,7 +177,7 @@ impl<'a> BinaryOperatorBase for EqualValue<'a> {
}
}

impl<'a> BinaryOperatorIndex for EqualValue<'a> {
impl BinaryOperatorIndex for EqualValue<'_> {
fn retrieve_matches<'b>(&'b self, lhs: &Match) -> Box<dyn Iterator<Item = Result<Match>> + 'b> {
let lhs = lhs.clone();
let lhs_val = try_as_boxed_iter!(self.value_for_match(&lhs, &self.spec_left));
Expand Down
6 changes: 3 additions & 3 deletions graphannis/src/annis/db/aql/operators/identical_cov.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@ impl<'a> IdenticalCoverage<'a> {
}
}

impl<'a> std::fmt::Display for IdenticalCoverage<'a> {
impl std::fmt::Display for IdenticalCoverage<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "_=_")
}
}

impl<'a> BinaryOperatorBase for IdenticalCoverage<'a> {
impl BinaryOperatorBase for IdenticalCoverage<'_> {
fn filter_match(&self, lhs: &Match, rhs: &Match) -> Result<bool> {
let start_lhs = self.tok_helper.left_token_for(lhs.node)?;
let end_lhs = self.tok_helper.right_token_for(lhs.node)?;
Expand Down Expand Up @@ -155,7 +155,7 @@ impl<'a> BinaryOperatorBase for IdenticalCoverage<'a> {
}
}

impl<'a> BinaryOperatorIndex for IdenticalCoverage<'a> {
impl BinaryOperatorIndex for IdenticalCoverage<'_> {
fn retrieve_matches(&self, lhs: &Match) -> Box<dyn Iterator<Item = Result<Match>>> {
let n_left = try_as_boxed_iter!(self.tok_helper.left_token_for(lhs.node));
let n_right = try_as_boxed_iter!(self.tok_helper.right_token_for(lhs.node));
Expand Down
6 changes: 3 additions & 3 deletions graphannis/src/annis/db/aql/operators/inclusion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ impl<'a> Inclusion<'a> {
}
}

impl<'a> std::fmt::Display for Inclusion<'a> {
impl std::fmt::Display for Inclusion<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "_i_")
}
}

impl<'a> BinaryOperatorBase for Inclusion<'a> {
impl BinaryOperatorBase for Inclusion<'_> {
fn filter_match(&self, lhs: &Match, rhs: &Match) -> Result<bool> {
let left_right_lhs = self.tok_helper.left_right_token_for(lhs.node)?;
let left_right_rhs = self.tok_helper.left_right_token_for(rhs.node)?;
Expand Down Expand Up @@ -160,7 +160,7 @@ enum NodeType {
Other(NodeID),
}

impl<'a> BinaryOperatorIndex for Inclusion<'a> {
impl BinaryOperatorIndex for Inclusion<'_> {
fn retrieve_matches<'b>(&'b self, lhs: &Match) -> Box<dyn Iterator<Item = Result<Match>> + 'b> {
let left_right_token = try_as_boxed_iter!(self.tok_helper.left_right_token_for(lhs.node));
if let (Some(start_lhs), Some(end_lhs)) = left_right_token {
Expand Down
6 changes: 3 additions & 3 deletions graphannis/src/annis/db/aql/operators/leftalignment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ impl<'a> LeftAlignment<'a> {
}
}

impl<'a> std::fmt::Display for LeftAlignment<'a> {
impl std::fmt::Display for LeftAlignment<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "_l_")
}
}

impl<'a> BinaryOperatorBase for LeftAlignment<'a> {
impl BinaryOperatorBase for LeftAlignment<'_> {
fn filter_match(&self, lhs: &Match, rhs: &Match) -> Result<bool> {
if let (Some(lhs_token), Some(rhs_token)) = (
self.tok_helper.left_token_for(lhs.node)?,
Expand Down Expand Up @@ -101,7 +101,7 @@ impl<'a> BinaryOperatorBase for LeftAlignment<'a> {
}
}

impl<'a> BinaryOperatorIndex for LeftAlignment<'a> {
impl BinaryOperatorIndex for LeftAlignment<'_> {
fn retrieve_matches(&self, lhs: &Match) -> Box<dyn Iterator<Item = Result<Match>>> {
let mut aligned = Vec::default();

Expand Down
6 changes: 3 additions & 3 deletions graphannis/src/annis/db/aql/operators/near.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@ impl<'a> Near<'a> {
}
}

impl<'a> std::fmt::Display for Near<'a> {
impl std::fmt::Display for Near<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "^{}", self.spec)
}
}

impl<'a> BinaryOperatorBase for Near<'a> {
impl BinaryOperatorBase for Near<'_> {
fn filter_match(&self, lhs: &Match, rhs: &Match) -> Result<bool> {
let start_end_forward = if self.spec.segmentation.is_some() {
(lhs.node, rhs.node)
Expand Down Expand Up @@ -195,7 +195,7 @@ impl<'a> BinaryOperatorBase for Near<'a> {
}
}

impl<'a> BinaryOperatorIndex for Near<'a> {
impl BinaryOperatorIndex for Near<'_> {
fn retrieve_matches(&self, lhs: &Match) -> Box<dyn Iterator<Item = Result<Match>>> {
let start_forward = if self.spec.segmentation.is_some() {
Some(lhs.node)
Expand Down
4 changes: 2 additions & 2 deletions graphannis/src/annis/db/aql/operators/negated_op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ pub struct NegatedOp<'a> {
negated_op: BinaryOperator<'a>,
}

impl<'a> Display for NegatedOp<'a> {
impl Display for NegatedOp<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "!",)?;
self.negated_op.fmt(f)?;
Ok(())
}
}

impl<'a> BinaryOperatorBase for NegatedOp<'a> {
impl BinaryOperatorBase for NegatedOp<'_> {
fn filter_match(&self, lhs: &Match, rhs: &Match) -> Result<bool> {
// Invert the filtered logic by the actual operator
let orig = self.negated_op.filter_match(lhs, rhs)?;
Expand Down
8 changes: 4 additions & 4 deletions graphannis/src/annis/db/aql/operators/non_existing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,14 @@ struct NonExistingUnaryOperatorIndex<'a> {
op_estimation: EstimationType,
}

impl<'a> Display for NonExistingUnaryOperatorIndex<'a> {
impl Display for NonExistingUnaryOperatorIndex<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, " !{} {}", self.negated_op, self.target)?;
Ok(())
}
}

impl<'a> UnaryOperator for NonExistingUnaryOperatorIndex<'a> {
impl UnaryOperator for NonExistingUnaryOperatorIndex<'_> {
fn filter_match(&self, m: &graphannis_core::annostorage::Match) -> Result<bool> {
// Extract the annotation keys for the matches
let it = self.negated_op.retrieve_matches(m).fuse().map(|m| match m {
Expand Down Expand Up @@ -200,7 +200,7 @@ struct NonExistingUnaryOperatorFilter<'a> {
op_estimation: EstimationType,
}

impl<'a> Display for NonExistingUnaryOperatorFilter<'a> {
impl Display for NonExistingUnaryOperatorFilter<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
if self.target_left {
write!(f, " !({} {} x)", self.target, self.negated_op)?;
Expand All @@ -211,7 +211,7 @@ impl<'a> Display for NonExistingUnaryOperatorFilter<'a> {
}
}

impl<'a> UnaryOperator for NonExistingUnaryOperatorFilter<'a> {
impl UnaryOperator for NonExistingUnaryOperatorFilter<'_> {
fn filter_match(&self, m: &graphannis_core::annostorage::Match) -> Result<bool> {
// The candidate match is on one side and we need to get an iterator of all possible matches for the other side
if let Ok(node_search) = NodeSearch::from_spec(
Expand Down
6 changes: 3 additions & 3 deletions graphannis/src/annis/db/aql/operators/overlap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl<'a> Overlap<'a> {
}
}

impl<'a> std::fmt::Display for Overlap<'a> {
impl std::fmt::Display for Overlap<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
if self.reflexive {
write!(f, "_o_reflexive_")
Expand All @@ -97,7 +97,7 @@ impl<'a> std::fmt::Display for Overlap<'a> {
}
}

impl<'a> BinaryOperatorBase for Overlap<'a> {
impl BinaryOperatorBase for Overlap<'_> {
fn filter_match(&self, lhs: &Match, rhs: &Match) -> Result<bool> {
if self.reflexive && lhs == rhs {
return Ok(true);
Expand Down Expand Up @@ -173,7 +173,7 @@ impl<'a> BinaryOperatorBase for Overlap<'a> {
}
}

impl<'a> BinaryOperatorIndex for Overlap<'a> {
impl BinaryOperatorIndex for Overlap<'_> {
fn retrieve_matches(&self, lhs: &Match) -> Box<dyn Iterator<Item = Result<Match>>> {
// use set to filter out duplicates
let mut result = FxHashSet::default();
Expand Down
12 changes: 6 additions & 6 deletions graphannis/src/annis/db/aql/operators/precedence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,13 @@ impl<'a> Precedence<'a> {
}
}

impl<'a> std::fmt::Display for Precedence<'a> {
impl std::fmt::Display for Precedence<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, ".{}", self.spec)
}
}

impl<'a> BinaryOperatorBase for Precedence<'a> {
impl BinaryOperatorBase for Precedence<'_> {
fn filter_match(&self, lhs: &Match, rhs: &Match) -> Result<bool> {
let start_end = if self.spec.segmentation.is_some() {
(lhs.node, rhs.node)
Expand Down Expand Up @@ -210,7 +210,7 @@ impl<'a> BinaryOperatorBase for Precedence<'a> {
}
}

impl<'a> BinaryOperatorIndex for Precedence<'a> {
impl BinaryOperatorIndex for Precedence<'_> {
fn retrieve_matches<'b>(&'b self, lhs: &Match) -> Box<dyn Iterator<Item = Result<Match>> + 'b> {
let start = if self.spec.segmentation.is_some() {
Some(lhs.node)
Expand Down Expand Up @@ -265,13 +265,13 @@ pub struct InversePrecedence<'a> {
spec: PrecedenceSpec,
}

impl<'a> std::fmt::Display for InversePrecedence<'a> {
impl std::fmt::Display for InversePrecedence<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, ".\u{20D6}{}", self.spec)
}
}

impl<'a> BinaryOperatorBase for InversePrecedence<'a> {
impl BinaryOperatorBase for InversePrecedence<'_> {
fn filter_match(&self, lhs: &Match, rhs: &Match) -> Result<bool> {
let start_end = if self.spec.segmentation.is_some() {
(lhs.node, rhs.node)
Expand Down Expand Up @@ -328,7 +328,7 @@ impl<'a> BinaryOperatorBase for InversePrecedence<'a> {
}
}

impl<'a> BinaryOperatorIndex for InversePrecedence<'a> {
impl BinaryOperatorIndex for InversePrecedence<'_> {
fn retrieve_matches<'b>(&'b self, lhs: &Match) -> Box<dyn Iterator<Item = Result<Match>> + 'b> {
let start = if self.spec.segmentation.is_some() {
Some(lhs.node)
Expand Down
6 changes: 3 additions & 3 deletions graphannis/src/annis/db/aql/operators/rightalignment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ impl<'a> RightAlignment<'a> {
}
}

impl<'a> std::fmt::Display for RightAlignment<'a> {
impl std::fmt::Display for RightAlignment<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "_r_")
}
}

impl<'a> BinaryOperatorBase for RightAlignment<'a> {
impl BinaryOperatorBase for RightAlignment<'_> {
fn filter_match(&self, lhs: &Match, rhs: &Match) -> Result<bool> {
if let (Some(lhs_token), Some(rhs_token)) = (
self.tok_helper.right_token_for(lhs.node)?,
Expand Down Expand Up @@ -101,7 +101,7 @@ impl<'a> BinaryOperatorBase for RightAlignment<'a> {
}
}

impl<'a> BinaryOperatorIndex for RightAlignment<'a> {
impl BinaryOperatorIndex for RightAlignment<'_> {
fn retrieve_matches(&self, lhs: &Match) -> Box<dyn Iterator<Item = Result<Match>>> {
let mut aligned = Vec::default();

Expand Down
1 change: 0 additions & 1 deletion graphannis/src/annis/db/corpusstorage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2079,7 +2079,6 @@ impl CorpusStorage {
/// the datasource, an edge in the special `Ordering/annis/datasource-gap`
/// component is added between the last token of each context region and the
/// first token of the next one.
pub fn subgraph(
&self,
corpus_name: &str,
Expand Down
4 changes: 2 additions & 2 deletions graphannis/src/annis/db/corpusstorage/subgraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct TokenIterator<'a> {
ordering_edges: Arc<dyn GraphStorage>,
}

impl<'a> TokenIterator<'a> {
impl TokenIterator<'_> {
fn calculate_covering_nodes(&mut self) -> Result<()> {
let mut covering_nodes = HashSet::new();

Expand All @@ -46,7 +46,7 @@ impl<'a> TokenIterator<'a> {
}
}

impl<'a> Iterator for TokenIterator<'a> {
impl Iterator for TokenIterator<'_> {
type Item = Result<NodeID>;

fn next(&mut self) -> Option<Self::Item> {
Expand Down
4 changes: 2 additions & 2 deletions graphannis/src/annis/db/exec/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,13 @@ impl<'a> Filter<'a> {
}
}

impl<'a> ExecutionNode for Filter<'a> {
impl ExecutionNode for Filter<'_> {
fn get_desc(&self) -> Option<&ExecutionNodeDesc> {
self.desc.as_ref()
}
}

impl<'a> Iterator for Filter<'a> {
impl Iterator for Filter<'_> {
type Item = Result<MatchGroup>;

fn next(&mut self) -> Option<Self::Item> {
Expand Down
4 changes: 2 additions & 2 deletions graphannis/src/annis/db/exec/indexjoin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,13 @@ impl<'a> IndexJoin<'a> {
}
}

impl<'a> ExecutionNode for IndexJoin<'a> {
impl ExecutionNode for IndexJoin<'_> {
fn get_desc(&self) -> Option<&ExecutionNodeDesc> {
Some(&self.desc)
}
}

impl<'a> Iterator for IndexJoin<'a> {
impl Iterator for IndexJoin<'_> {
type Item = Result<MatchGroup>;

fn next(&mut self) -> Option<Self::Item> {
Expand Down
Loading

0 comments on commit 3f8620e

Please sign in to comment.