From e37775fe219ade97e5cde055c90b7fb0b7abca65 Mon Sep 17 00:00:00 2001 From: Antoine G <325288+saroh@users.noreply.github.com> Date: Wed, 2 Mar 2022 03:00:00 +0100 Subject: [PATCH] iff->if or if and only if (#1298) * has_xxx is_xxx -> if, these function usualy define equivalence xxx returns bool -> specify equivalence when appropriate * fix doc --- src/collector/top_collector.rs | 3 +-- src/core/segment_reader.rs | 4 ++-- src/directory/directory.rs | 2 +- src/directory/managed_directory.rs | 2 +- src/fastfield/alive_bitset.rs | 4 ++-- src/indexer/delete_queue.rs | 2 +- src/postings/block_segment_postings.rs | 2 +- src/query/boolean_query/boolean_weight.rs | 2 +- src/query/phrase_query/phrase_scorer.rs | 2 +- src/query/query_parser/query_parser.rs | 2 +- src/schema/bytes_options.rs | 12 ++++++------ src/schema/document.rs | 2 +- src/schema/facet.rs | 2 +- src/schema/facet_options.rs | 2 +- src/schema/field_entry.rs | 8 ++++---- src/schema/field_type.rs | 4 ++-- src/schema/index_record_option.rs | 4 ++-- src/schema/json_object_options.rs | 2 +- src/schema/numeric_options.rs | 2 +- src/schema/text_options.rs | 4 ++-- src/termdict/fst_termdict/termdict.rs | 5 +++-- src/termdict/sstable_termdict/merger.rs | 4 ++-- src/termdict/sstable_termdict/termdict.rs | 2 +- 23 files changed, 39 insertions(+), 39 deletions(-) diff --git a/src/collector/top_collector.rs b/src/collector/top_collector.rs index e37272a9f..03c923d76 100644 --- a/src/collector/top_collector.rs +++ b/src/collector/top_collector.rs @@ -173,8 +173,7 @@ impl TopSegmentCollector { .collect() } - /// Return true iff at least K documents have gone through - /// the collector. + /// Return true if more documents have been collected than the limit. #[inline] pub(crate) fn at_capacity(&self) -> bool { self.heap.len() >= self.limit diff --git a/src/core/segment_reader.rs b/src/core/segment_reader.rs index c6288170f..ce050295e 100644 --- a/src/core/segment_reader.rs +++ b/src/core/segment_reader.rs @@ -70,7 +70,7 @@ impl SegmentReader { self.max_doc - self.num_docs } - /// Returns true iff some of the documents of the segment have been deleted. + /// Returns true if some of the documents of the segment have been deleted. pub fn has_deletes(&self) -> bool { self.num_deleted_docs() > 0 } @@ -301,7 +301,7 @@ impl SegmentReader { self.alive_bitset_opt.as_ref() } - /// Returns true iff the `doc` is marked + /// Returns true if the `doc` is marked /// as deleted. pub fn is_deleted(&self, doc: DocId) -> bool { self.alive_bitset() diff --git a/src/directory/directory.rs b/src/directory/directory.rs index 11c9acec0..e54b8dee3 100644 --- a/src/directory/directory.rs +++ b/src/directory/directory.rs @@ -128,7 +128,7 @@ pub trait Directory: DirectoryClone + fmt::Debug + Send + Sync + 'static { /// `DeleteError::DoesNotExist`. fn delete(&self, path: &Path) -> Result<(), DeleteError>; - /// Returns true iff the file exists + /// Returns true if and only if the file exists fn exists(&self, path: &Path) -> Result; /// Opens a writer for the *virtual file* associated with diff --git a/src/directory/managed_directory.rs b/src/directory/managed_directory.rs index 0a5080052..b15335567 100644 --- a/src/directory/managed_directory.rs +++ b/src/directory/managed_directory.rs @@ -16,7 +16,7 @@ use crate::directory::{ use crate::error::DataCorruption; use crate::Directory; -/// Returns true iff the file is "managed". +/// Returns true if the file is "managed". /// Non-managed file are not subject to garbage collection. /// /// Filenames that starts by a "." -typically locks- diff --git a/src/fastfield/alive_bitset.rs b/src/fastfield/alive_bitset.rs index 3eca5e5bc..bea0120fd 100644 --- a/src/fastfield/alive_bitset.rs +++ b/src/fastfield/alive_bitset.rs @@ -61,13 +61,13 @@ impl AliveBitSet { AliveBitSet::from(bitset) } - /// Returns true iff the document is still "alive". In other words, if it has not been deleted. + /// Returns true if the document is still "alive". In other words, if it has not been deleted. #[inline] pub fn is_alive(&self, doc: DocId) -> bool { self.bitset.contains(doc) } - /// Returns true iff the document has been marked as deleted. + /// Returns true if the document has been marked as deleted. #[inline] pub fn is_deleted(&self, doc: DocId) -> bool { !self.is_alive(doc) diff --git a/src/indexer/delete_queue.rs b/src/indexer/delete_queue.rs index fb39bd089..8cd4deea4 100644 --- a/src/indexer/delete_queue.rs +++ b/src/indexer/delete_queue.rs @@ -221,7 +221,7 @@ impl DeleteCursor { } /// Advance to the next delete operation. - /// Returns true iff there is such an operation. + /// Returns true if and only if there is such an operation. pub fn advance(&mut self) -> bool { if self.load_block_if_required() { self.pos += 1; diff --git a/src/postings/block_segment_postings.rs b/src/postings/block_segment_postings.rs index ad2d8aba1..567dd9a69 100644 --- a/src/postings/block_segment_postings.rs +++ b/src/postings/block_segment_postings.rs @@ -322,7 +322,7 @@ impl BlockSegmentPostings { /// Advance to the next block. /// - /// Returns false iff there was no remaining blocks. + /// Returns false if and only if there is no remaining block. pub fn advance(&mut self) { self.skip_reader.advance(); self.block_max_score_cache = None; diff --git a/src/query/boolean_query/boolean_weight.rs b/src/query/boolean_query/boolean_weight.rs index 522da9058..f2a5fd376 100644 --- a/src/query/boolean_query/boolean_weight.rs +++ b/src/query/boolean_query/boolean_weight.rs @@ -35,7 +35,7 @@ where TScoreCombiner: ScoreCombiner { .iter() .all(|scorer| scorer.freq_reading_option() == FreqReadingOption::ReadFreq) { - // Block wand is only available iff we read frequencies. + // Block wand is only available if we read frequencies. return SpecializedScorer::TermUnion(scorers); } else { return SpecializedScorer::Other(Box::new(Union::<_, TScoreCombiner>::from( diff --git a/src/query/phrase_query/phrase_scorer.rs b/src/query/phrase_query/phrase_scorer.rs index e0eeec294..4f8d45894 100644 --- a/src/query/phrase_query/phrase_scorer.rs +++ b/src/query/phrase_query/phrase_scorer.rs @@ -54,7 +54,7 @@ pub struct PhraseScorer { scoring_enabled: bool, } -/// Returns true iff the two sorted array contain a common element +/// Returns true if and only if the two sorted arrays contain a common element fn intersection_exists(left: &[u32], right: &[u32]) -> bool { let mut left_i = 0; let mut right_i = 0; diff --git a/src/query/query_parser/query_parser.rs b/src/query/query_parser/query_parser.rs index 228ec6ad4..9b9d9ef31 100644 --- a/src/query/query_parser/query_parser.rs +++ b/src/query/query_parser/query_parser.rs @@ -75,7 +75,7 @@ pub enum QueryParserError { /// Recursively remove empty clause from the AST /// -/// Returns `None` iff the `logical_ast` ended up being empty. +/// Returns `None` if and only if the `logical_ast` ended up being empty. fn trim_ast(logical_ast: LogicalAst) -> Option { match logical_ast { LogicalAst::Clause(children) => { diff --git a/src/schema/bytes_options.rs b/src/schema/bytes_options.rs index 6ee1666f7..871e24dfc 100644 --- a/src/schema/bytes_options.rs +++ b/src/schema/bytes_options.rs @@ -14,9 +14,9 @@ pub struct BytesOptions { } /// For backward compability we add an intermediary to interpret the -/// lack of fieldnorms attribute as "true" iff indexed. +/// lack of fieldnorms attribute as "true" if and only if indexed. /// -/// (Downstream, for the moment, this attribute is not used anyway if not indexed...) +/// (Downstream, for the moment, this attribute is not used if not indexed...) /// Note that: newly serialized NumericOptions will include the new attribute. #[derive(Deserialize)] struct BytesOptionsDeser { @@ -39,22 +39,22 @@ impl From for BytesOptions { } impl BytesOptions { - /// Returns true iff the value is indexed. + /// Returns true if the value is indexed. pub fn is_indexed(&self) -> bool { self.indexed } - /// Returns true iff the value is normed. + /// Returns true if and only if the value is normed. pub fn fieldnorms(&self) -> bool { self.fieldnorms } - /// Returns true iff the value is a fast field. + /// Returns true if the value is a fast field. pub fn is_fast(&self) -> bool { self.fast } - /// Returns true iff the value is stored. + /// Returns true if the value is stored. pub fn is_stored(&self) -> bool { self.stored } diff --git a/src/schema/document.rs b/src/schema/document.rs index c9da05b53..21b4c42a3 100644 --- a/src/schema/document.rs +++ b/src/schema/document.rs @@ -71,7 +71,7 @@ impl Document { self.field_values.len() } - /// Returns true iff the document contains no fields. + /// Returns true if the document contains no fields. pub fn is_empty(&self) -> bool { self.field_values.is_empty() } diff --git a/src/schema/facet.rs b/src/schema/facet.rs index 658bed748..a7d997d8d 100644 --- a/src/schema/facet.rs +++ b/src/schema/facet.rs @@ -49,7 +49,7 @@ impl Facet { Facet("".to_string()) } - /// Returns true iff the facet is the root facet `/`. + /// Returns true if the facet is the root facet `/`. pub fn is_root(&self) -> bool { self.encoded_str().is_empty() } diff --git a/src/schema/facet_options.rs b/src/schema/facet_options.rs index eace12f2f..85d433a34 100644 --- a/src/schema/facet_options.rs +++ b/src/schema/facet_options.rs @@ -13,7 +13,7 @@ pub struct FacetOptions { } impl FacetOptions { - /// Returns true iff the value is stored. + /// Returns true if the value is stored. pub fn is_stored(&self) -> bool { self.stored } diff --git a/src/schema/field_entry.rs b/src/schema/field_entry.rs index 81a4aa917..deda4dc1c 100644 --- a/src/schema/field_entry.rs +++ b/src/schema/field_entry.rs @@ -79,19 +79,19 @@ impl FieldEntry { &self.field_type } - /// Returns true iff the field is indexed. + /// Returns true if the field is indexed. /// /// An indexed field is searchable. pub fn is_indexed(&self) -> bool { self.field_type.is_indexed() } - /// Returns true iff the field is normed + /// Returns true if the field is normed pub fn has_fieldnorms(&self) -> bool { self.field_type.has_fieldnorms() } - /// Returns true iff the field is a int (signed or unsigned) fast field + /// Returns true if the field is a int (signed or unsigned) fast field pub fn is_fast(&self) -> bool { match self.field_type { FieldType::U64(ref options) @@ -102,7 +102,7 @@ impl FieldEntry { } } - /// Returns true iff the field is stored + /// Returns true if the field is stored pub fn is_stored(&self) -> bool { match self.field_type { FieldType::U64(ref options) diff --git a/src/schema/field_type.rs b/src/schema/field_type.rs index 22ae8180f..c52e8adfa 100644 --- a/src/schema/field_type.rs +++ b/src/schema/field_type.rs @@ -148,7 +148,7 @@ impl FieldType { } } - /// returns true iff the field is indexed. + /// returns true if the field is indexed. pub fn is_indexed(&self) -> bool { match *self { FieldType::Str(ref text_options) => text_options.get_indexing_options().is_some(), @@ -183,7 +183,7 @@ impl FieldType { } } - /// returns true iff the field is normed. + /// returns true if the field is normed. pub fn has_fieldnorms(&self) -> bool { match *self { FieldType::Str(ref text_options) => text_options diff --git a/src/schema/index_record_option.rs b/src/schema/index_record_option.rs index 8648b1117..395b102c2 100644 --- a/src/schema/index_record_option.rs +++ b/src/schema/index_record_option.rs @@ -30,7 +30,7 @@ pub enum IndexRecordOption { } impl IndexRecordOption { - /// Returns true iff this option includes encoding + /// Returns true if this option includes encoding /// term frequencies. pub fn has_freq(self) -> bool { match self { @@ -39,7 +39,7 @@ impl IndexRecordOption { } } - /// Returns true iff this option include encoding + /// Returns true if this option include encoding /// term positions. pub fn has_positions(self) -> bool { match self { diff --git a/src/schema/json_object_options.rs b/src/schema/json_object_options.rs index 2a0795c12..1bbd90889 100644 --- a/src/schema/json_object_options.rs +++ b/src/schema/json_object_options.rs @@ -16,7 +16,7 @@ pub struct JsonObjectOptions { } impl JsonObjectOptions { - /// Returns `true` iff the json object should be stored. + /// Returns `true` if the json object should be stored. pub fn is_stored(&self) -> bool { self.stored } diff --git a/src/schema/numeric_options.rs b/src/schema/numeric_options.rs index 8e0d117e5..9853e018d 100644 --- a/src/schema/numeric_options.rs +++ b/src/schema/numeric_options.rs @@ -33,7 +33,7 @@ pub struct NumericOptions { } /// For backward compability we add an intermediary to interpret the -/// lack of fieldnorms attribute as "true" iff indexed. +/// lack of fieldnorms attribute as "true" if and only if indexed. /// /// (Downstream, for the moment, this attribute is not used anyway if not indexed...) /// Note that: newly serialized NumericOptions will include the new attribute. diff --git a/src/schema/text_options.rs b/src/schema/text_options.rs index 45fa3b488..63ad52b48 100644 --- a/src/schema/text_options.rs +++ b/src/schema/text_options.rs @@ -19,7 +19,7 @@ impl TextOptions { self.indexing.as_ref() } - /// Returns true iff the text is to be stored. + /// Returns true if the text is to be stored. pub fn is_stored(&self) -> bool { self.stored } @@ -83,7 +83,7 @@ impl TextFieldIndexing { self } - /// Returns true iff fieldnorms are stored. + /// Returns true if and only if fieldnorms are stored. pub fn fieldnorms(&self) -> bool { self.fieldnorms } diff --git a/src/termdict/fst_termdict/termdict.rs b/src/termdict/fst_termdict/termdict.rs index 9469e6ab3..937471733 100644 --- a/src/termdict/fst_termdict/termdict.rs +++ b/src/termdict/fst_termdict/termdict.rs @@ -143,12 +143,13 @@ impl TermDictionary { Ok(self.fst_index.get(key)) } - /// Returns the term associated to a given term ordinal. + /// Stores the term associated to a given term ordinal in + /// a `bytes` buffer. /// /// Term ordinals are defined as the position of the term in /// the sorted list of terms. /// - /// Returns true iff the term has been found. + /// Returns true if and only if the term has been found. /// /// Regardless of whether the term is found or not, /// the buffer may be modified. diff --git a/src/termdict/sstable_termdict/merger.rs b/src/termdict/sstable_termdict/merger.rs index 6c98498ec..e502aeb4d 100644 --- a/src/termdict/sstable_termdict/merger.rs +++ b/src/termdict/sstable_termdict/merger.rs @@ -98,7 +98,7 @@ impl<'a> TermMerger<'a> { /// Returns the current term. /// /// This method may be called - /// iff advance() has been called before + /// if and only if advance() has been called before /// and "true" was returned. pub fn key(&self) -> &[u8] { self.current_streamers[0].streamer.key() @@ -108,7 +108,7 @@ impl<'a> TermMerger<'a> { /// that include the current term. /// /// This method may be called - /// iff advance() has been called before + /// if and only if advance() has been called before /// and "true" was returned. pub fn current_segment_ords_and_term_infos<'b: 'a>( &'b self, diff --git a/src/termdict/sstable_termdict/termdict.rs b/src/termdict/sstable_termdict/termdict.rs index b4ff1b66f..169cedad1 100644 --- a/src/termdict/sstable_termdict/termdict.rs +++ b/src/termdict/sstable_termdict/termdict.rs @@ -171,7 +171,7 @@ impl TermDictionary { /// Term ordinals are defined as the position of the term in /// the sorted list of terms. /// - /// Returns true iff the term has been found. + /// Returns true if and only if the term has been found. /// /// Regardless of whether the term is found or not, /// the buffer may be modified.