diff --git a/src/layer/builder.rs b/src/layer/builder.rs index d7e64034..f0b8f3d5 100644 --- a/src/layer/builder.rs +++ b/src/layer/builder.rs @@ -65,11 +65,8 @@ impl DictionarySetFileBuilder { /// /// Panics if the given predicate string is not a lexical successor of the previous node string. pub fn add_predicate(&mut self, predicate: &str) -> u64 { - let id = self - .predicate_dictionary_builder - .add(Bytes::copy_from_slice(predicate.as_bytes())); - - id + self.predicate_dictionary_builder + .add(Bytes::copy_from_slice(predicate.as_bytes())) } pub fn add_predicate_bytes(&mut self, predicate: Bytes) -> u64 { @@ -82,9 +79,7 @@ impl DictionarySetFileBuilder { /// /// Panics if the given value string is not a lexical successor of the previous value string. pub fn add_value(&mut self, value: TypedDictEntry) -> u64 { - let id = self.value_dictionary_builder.add(value); - - id + self.value_dictionary_builder.add(value) } /// Add nodes from an iterable. diff --git a/src/layer/internal/base.rs b/src/layer/internal/base.rs index d1b2033d..ad83b0d9 100644 --- a/src/layer/internal/base.rs +++ b/src/layer/internal/base.rs @@ -173,9 +173,7 @@ impl BaseLayerFileBuilder { /// /// Panics if the given node string is not a lexical successor of the previous node string. pub fn add_node(&mut self, node: &str) -> u64 { - let id = self.builder.add_node(node); - - id + self.builder.add_node(node) } pub fn add_node_bytes(&mut self, node: Bytes) -> u64 { @@ -186,9 +184,7 @@ impl BaseLayerFileBuilder { /// /// Panics if the given predicate string is not a lexical successor of the previous node string. pub fn add_predicate(&mut self, predicate: &str) -> u64 { - let id = self.builder.add_predicate(predicate); - - id + self.builder.add_predicate(predicate) } pub fn add_predicate_bytes(&mut self, predicate: Bytes) -> u64 { @@ -199,9 +195,7 @@ impl BaseLayerFileBuilder { /// /// Panics if the given value string is not a lexical successor of the previous value string. pub fn add_value(&mut self, value: TypedDictEntry) -> u64 { - let id = self.builder.add_value(value); - - id + self.builder.add_value(value) } /// Add nodes from an iterable. @@ -215,9 +209,7 @@ impl BaseLayerFileBuilder { ::IntoIter: Unpin + Send + Sync, I: Unpin + Sync, { - let ids = self.builder.add_nodes(nodes); - - ids + self.builder.add_nodes(nodes) } pub fn add_nodes_bytes + Send>( @@ -244,9 +236,7 @@ impl BaseLayerFileBuilder { ::IntoIter: Unpin + Send + Sync, I: Unpin + Sync, { - let ids = self.builder.add_predicates(predicates); - - ids + self.builder.add_predicates(predicates) } pub fn add_predicates_bytes + Send>( @@ -273,9 +263,7 @@ impl BaseLayerFileBuilder { ::IntoIter: Unpin + Send + Sync, I: Unpin + Sync, { - let ids = self.builder.add_values(values); - - ids + self.builder.add_values(values) } /// Turn this builder into a phase 2 builder that will take triple data. diff --git a/src/layer/internal/mod.rs b/src/layer/internal/mod.rs index cd8d3455..2651a98d 100644 --- a/src/layer/internal/mod.rs +++ b/src/layer/internal/mod.rs @@ -524,10 +524,7 @@ impl InternalLayer { } pub fn is_rollup(&self) -> bool { - match self { - Rollup(_) => true, - _ => false, - } + matches!(self, Rollup(_)) } } @@ -635,7 +632,7 @@ impl Layer for InternalLayer { parent_count = parent_count - current_layer.node_dict_len() as u64 - current_layer.value_dict_len() as u64; - if corrected_id > parent_count as u64 { + if corrected_id > parent_count { // subject, if it exists, is in this layer corrected_id -= parent_count; } else { @@ -666,7 +663,7 @@ impl Layer for InternalLayer { let mut corrected_id = id; if let Some(parent) = current_layer.immediate_parent() { parent_count -= current_layer.predicate_dict_len() as u64; - if corrected_id > parent_count as u64 { + if corrected_id > parent_count { // subject, if it exists, is in this layer corrected_id -= parent_count; } else { diff --git a/src/layer/internal/object_iterator.rs b/src/layer/internal/object_iterator.rs index aa2faf9e..e130cfa5 100644 --- a/src/layer/internal/object_iterator.rs +++ b/src/layer/internal/object_iterator.rs @@ -22,10 +22,10 @@ impl InternalLayerTripleObjectIterator { s_p_adjacency_list: AdjacencyList, ) -> Self { Self { - subjects: subjects, - objects: objects, - o_ps_adjacency_list: o_ps_adjacency_list, - s_p_adjacency_list: s_p_adjacency_list, + subjects, + objects, + o_ps_adjacency_list, + s_p_adjacency_list, o_position: 0, o_ps_position: 0, peeked: None, diff --git a/src/layer/internal/subject_iterator.rs b/src/layer/internal/subject_iterator.rs index 7321d349..1c8b1cdd 100644 --- a/src/layer/internal/subject_iterator.rs +++ b/src/layer/internal/subject_iterator.rs @@ -22,9 +22,9 @@ impl InternalLayerTripleSubjectIterator { sp_o_adjacency_list: AdjacencyList, ) -> Self { Self { - subjects: subjects, - s_p_adjacency_list: s_p_adjacency_list, - sp_o_adjacency_list: sp_o_adjacency_list, + subjects, + s_p_adjacency_list, + sp_o_adjacency_list, s_position: 0, s_p_position: 0, sp_o_position: 0, @@ -422,7 +422,7 @@ impl Iterator for InternalTripleStackIterator { (Some(lowest_pos_index), Some(lowest_neg_index)) => { let lowest_pos = self.positives[lowest_pos_index].peek().unwrap(); let lowest_neg = self.negatives[lowest_neg_index].peek().unwrap(); - match lowest_pos.cmp(&lowest_neg) { + match lowest_pos.cmp(lowest_neg) { Ordering::Less => { // next change is an addition, and there's no matching removal return Some(( @@ -479,7 +479,7 @@ mod tests { #[tokio::test] async fn base_triple_removal_iterator() { - let base_layer: InternalLayer = example_base_layer().await.into(); + let base_layer: InternalLayer = example_base_layer().await; let triples: Vec<_> = base_layer.internal_triple_removals().collect(); assert!(triples.is_empty()); @@ -811,7 +811,7 @@ mod tests { async fn child_layer() -> InternalLayer { let base_layer = example_base_layer().await; - let parent: Arc = Arc::new(base_layer.into()); + let parent: Arc = Arc::new(base_layer); let child_files = child_layer_files(); @@ -830,7 +830,6 @@ mod tests { ChildLayer::load_from_files([5, 4, 3, 2, 1], parent, &child_files) .await .unwrap() - .into() } #[tokio::test] @@ -1032,7 +1031,7 @@ mod tests { async fn iterate_partial_stack() { let (parent_id, layer) = create_stack_for_partial_tests().await; - let iterator = InternalTripleStackIterator::from_layer_stack(&*layer, parent_id).unwrap(); + let iterator = InternalTripleStackIterator::from_layer_stack(&layer, parent_id).unwrap(); let changes: Vec<_> = iterator .map(|t| (t.0, layer.id_triple_to_string(&t.1).unwrap())) .collect(); diff --git a/src/layer/layer.rs b/src/layer/layer.rs index 51652384..7b4ed487 100644 --- a/src/layer/layer.rs +++ b/src/layer/layer.rs @@ -98,8 +98,8 @@ pub trait Layer: Send + Sync { self.subject_id(&triple.subject).and_then(|subject| { self.predicate_id(&triple.predicate).and_then(|predicate| { match &triple.object { - ObjectType::Node(node) => self.object_node_id(&node), - ObjectType::Value(value) => self.object_value_id(&value), + ObjectType::Node(node) => self.object_node_id(node), + ObjectType::Value(value) => self.object_value_id(value), } .map(|object| IdTriple { subject, @@ -127,11 +127,11 @@ pub trait Layer: Send + Sync { .unwrap_or(PossiblyResolved::Unresolved(triple.predicate)), object: match &triple.object { ObjectType::Node(node) => self - .object_node_id(&node) + .object_node_id(node) .map(PossiblyResolved::Resolved) .unwrap_or(PossiblyResolved::Unresolved(triple.object)), ObjectType::Value(value) => self - .object_value_id(&value) + .object_value_id(value) .map(PossiblyResolved::Resolved) .unwrap_or(PossiblyResolved::Unresolved(triple.object)), }, @@ -270,7 +270,7 @@ impl PossiblyResolved { /// Return a PossiblyResolved with the inner value as a reference. pub fn as_ref(&self) -> PossiblyResolved<&T> { match self { - Self::Unresolved(u) => PossiblyResolved::Unresolved(&u), + Self::Unresolved(u) => PossiblyResolved::Unresolved(u), Self::Resolved(id) => PossiblyResolved::Resolved(*id), } } @@ -426,8 +426,7 @@ mod tests { let base: Arc = Arc::new( BaseLayer::load_from_files([1, 2, 3, 4, 5], &files) .await - .unwrap() - .into(), + .unwrap(), ); let files = child_layer_files(); @@ -439,8 +438,7 @@ mod tests { let child: Arc = Arc::new( ChildLayer::load_from_files([5, 4, 3, 2, 1], base.clone(), &files) .await - .unwrap() - .into(), + .unwrap(), ); // TODO why are we not using these results? @@ -633,8 +631,7 @@ mod tests { let base: Arc = Arc::new( BaseLayer::load_from_files([1, 2, 3, 4, 5], &files) .await - .unwrap() - .into(), + .unwrap(), ); let mut results: Vec<_> = base diff --git a/src/layer/simple_builder.rs b/src/layer/simple_builder.rs index 90c4a23e..81c25bb7 100644 --- a/src/layer/simple_builder.rs +++ b/src/layer/simple_builder.rs @@ -287,7 +287,7 @@ fn zero_equivalents( let mut removals_iter = removals.iter_mut().peekable(); 'outer: for mut addition in additions { let mut next = removals_iter.peek(); - if next == None { + if next.is_none() { break; } @@ -296,7 +296,7 @@ fn zero_equivalents( removals_iter.next().unwrap(); next = removals_iter.peek(); - if next == None { + if next.is_none() { break 'outer; } else if next >= Some(&addition) { break; diff --git a/src/storage/archive.rs b/src/storage/archive.rs index 41af06ac..6a7d146a 100644 --- a/src/storage/archive.rs +++ b/src/storage/archive.rs @@ -608,11 +608,7 @@ impl ConstructionFile { fn is_finalized(&self) -> bool { let guard = self.0.read().unwrap(); - if let ConstructionFileState::Finalized(_) = &*guard { - true - } else { - false - } + matches!(&*guard, ConstructionFileState::Finalized(_)) } fn finalized_buf(self) -> Bytes { @@ -953,7 +949,7 @@ impl AsyncRead for ArchiveSliceReader { } let read = AsyncRead::poll_read(Pin::new(&mut self.file), cx, buf); - if let Poll::Pending = read { + if read.is_pending() { return Poll::Pending; } diff --git a/src/storage/consts.rs b/src/storage/consts.rs index bae2d668..b6a66766 100644 --- a/src/storage/consts.rs +++ b/src/storage/consts.rs @@ -505,7 +505,7 @@ lazy_static! { ]); } -pub const SHARED_REQUIRED_FILES: [&'static str; 8] = [ +pub const SHARED_REQUIRED_FILES: [&str; 8] = [ FILENAMES.node_dictionary_blocks, FILENAMES.node_dictionary_offsets, FILENAMES.predicate_dictionary_blocks, @@ -516,7 +516,7 @@ pub const SHARED_REQUIRED_FILES: [&'static str; 8] = [ FILENAMES.value_dictionary_offsets, ]; -pub const SHARED_OPTIONAL_FILES: [&'static str; 7] = [ +pub const SHARED_OPTIONAL_FILES: [&str; 7] = [ FILENAMES.node_value_idmap_bits, FILENAMES.node_value_idmap_bit_index_blocks, FILENAMES.node_value_idmap_bit_index_sblocks, @@ -526,7 +526,7 @@ pub const SHARED_OPTIONAL_FILES: [&'static str; 7] = [ FILENAMES.rollup, ]; -pub const BASE_LAYER_REQUIRED_FILES: [&'static str; 15] = [ +pub const BASE_LAYER_REQUIRED_FILES: [&str; 15] = [ FILENAMES.base_s_p_adjacency_list_nums, FILENAMES.base_s_p_adjacency_list_bits, FILENAMES.base_s_p_adjacency_list_bit_index_blocks, @@ -544,10 +544,9 @@ pub const BASE_LAYER_REQUIRED_FILES: [&'static str; 15] = [ FILENAMES.base_predicate_wavelet_tree_bit_index_sblocks, ]; -pub const BASE_LAYER_OPTIONAL_FILES: [&'static str; 2] = - [FILENAMES.base_subjects, FILENAMES.base_objects]; +pub const BASE_LAYER_OPTIONAL_FILES: [&str; 2] = [FILENAMES.base_subjects, FILENAMES.base_objects]; -pub const CHILD_LAYER_REQUIRED_FILES: [&'static str; 31] = [ +pub const CHILD_LAYER_REQUIRED_FILES: [&str; 31] = [ FILENAMES.parent, FILENAMES.pos_s_p_adjacency_list_nums, FILENAMES.pos_s_p_adjacency_list_bits, @@ -581,7 +580,7 @@ pub const CHILD_LAYER_REQUIRED_FILES: [&'static str; 31] = [ FILENAMES.neg_predicate_wavelet_tree_bit_index_sblocks, ]; -pub const CHILD_LAYER_OPTIONAL_FILES: [&'static str; 4] = [ +pub const CHILD_LAYER_OPTIONAL_FILES: [&str; 4] = [ FILENAMES.pos_subjects, FILENAMES.pos_objects, FILENAMES.neg_subjects, diff --git a/src/storage/delta.rs b/src/storage/delta.rs index fb291899..01b65096 100644 --- a/src/storage/delta.rs +++ b/src/storage/delta.rs @@ -19,7 +19,7 @@ async fn safe_upto_bound( .retrieve_layer_stack_names_upto(layer.name(), upto) .await?; - let mut l = &*layer; + let mut l = layer; loop { let parent = match l.immediate_parent() { None => { @@ -487,8 +487,7 @@ mod tests { let delta_layer: Arc = Arc::new( BaseLayer::load_from_files([0, 0, 0, 0, 4], &delta_files) .await - .unwrap() - .into(), + .unwrap(), ); let expected: Vec<_> = layer diff --git a/src/storage/directory.rs b/src/storage/directory.rs index 54702adc..342cffe0 100644 --- a/src/storage/directory.rs +++ b/src/storage/directory.rs @@ -193,7 +193,7 @@ impl DirectoryLabelStore { } fn get_label_from_data(name: String, data: &[u8]) -> io::Result