chore: cargo style fix

This commit is contained in:
Zixuan Chen 2022-10-21 12:58:11 +08:00
parent 36adcd0ba3
commit 0cd640340a
11 changed files with 62 additions and 73 deletions

View file

@ -3,11 +3,7 @@ use std::ptr::NonNull;
use enum_as_inner::EnumAsInner;
use fxhash::FxHashMap;
use crate::{
log_store::{LogStoreRef, LogStoreWeakRef},
span::IdSpan,
LogStore,
};
use crate::{log_store::LogStoreWeakRef, span::IdSpan, LogStore};
use super::{
map::MapContainer, text::text_container::TextContainer, Container, ContainerID, ContainerType,

View file

@ -1,5 +1,4 @@
use std::{
borrow::Cow,
fmt::Debug,
ops::{Deref, DerefMut},
ptr::NonNull,
@ -12,7 +11,7 @@ use rle::{
rle_tree::{node::LeafNode, Position, SafeCursor, SafeCursorMut, UnsafeCursor},
HasLength, Mergable, RleVec, Sliceable, ZeroElement,
};
use smallvec::SmallVec;
use crate::{
id::ID,

View file

@ -300,60 +300,52 @@ pub mod fuzz {
5,
100,
vec![
Delete {
client_id: 252,
pos: 58,
len: 182,
},
Delete {
client_id: 247,
pos: 255,
len: 134,
NewOp {
client_id: 255,
pos: 11,
},
NewOp {
client_id: 252,
pos: 152,
client_id: 255,
pos: 252,
},
NewOp {
client_id: 2,
client_id: 255,
pos: 64,
},
NewOp {
client_id: 151,
pos: 151,
},
NewOp {
client_id: 151,
pos: 151,
},
NewOp {
client_id: 255,
pos: 252,
},
NewOp {
client_id: 151,
pos: 158,
},
Delete {
client_id: 2,
pos: 0,
len: 162,
NewOp {
client_id: 254,
pos: 121,
},
Delete {
client_id: 162,
pos: 217,
len: 176,
NewOp {
client_id: 3,
pos: 255,
},
Delete {
client_id: 177,
pos: 241,
len: 177,
NewOp {
client_id: 0,
pos: 144,
},
Delete {
client_id: 253,
pos: 10,
len: 2,
},
Sync { from: 0, to: 0 },
Sync { from: 92, to: 255 },
Delete {
client_id: 255,
pos: 255,
len: 134,
},
NewOp {
client_id: 252,
pos: 152,
},
Delete {
client_id: 0,
pos: 144,
len: 144,
},
Sync { from: 29, to: 29 },
],
)
}

View file

@ -918,6 +918,7 @@ mod find_common_ancestors_proptest {
}
let mut expected = Vec::with_capacity(N);
#[allow(clippy::needless_range_loop)]
for i in 0..N {
dags[i].push(1);
expected.push(dags[i].frontier[0]);
@ -1015,7 +1016,7 @@ mod find_common_ancestors_proptest {
#[cfg(test)]
mod dag_partial_iter {
use crate::{dag::iter::IterReturn, span::CounterSpan, tests::PROPTEST_FACTOR_10};
use crate::{dag::iter::IterReturn, tests::PROPTEST_FACTOR_10};
use super::*;
@ -1057,7 +1058,7 @@ mod dag_partial_iter {
break;
}
for &(j, (other_node, other_vv)) in vec.iter() {
for &(j, (_other_node, other_vv)) in vec.iter() {
if i >= j {
continue;
}

View file

@ -81,7 +81,7 @@ impl Actionable for String {
fn preprocess(&self, action: &mut Action) {
action.preprocess(self.len());
match action {
Action::Ins { content, pos } => {
Action::Ins { pos, .. } => {
while !self.is_char_boundary(*pos) {
*pos = (*pos + 1) % (self.len() + 1)
}
@ -122,7 +122,7 @@ impl Actionable for TextContainer {
}
}
fn preprocess(&self, action: &mut Action) {
fn preprocess(&self, _action: &mut Action) {
unreachable!();
}
}

View file

@ -30,7 +30,7 @@ mod value;
pub(crate) mod macros;
pub(crate) use change::{Lamport, Timestamp};
pub(crate) use id::{ClientID, ID};
pub(crate) use op::{ContentType, InsertContentTrait, Op, OpContent, OpType};
pub(crate) use op::{ContentType, InsertContentTrait, Op, OpType};
pub(crate) type InternalString = DefaultAtom;

View file

@ -1,6 +1,3 @@
use std::cmp::Reverse;
use std::collections::BinaryHeap;
use crate::Op;
use crate::change::Lamport;

View file

@ -14,7 +14,6 @@ use crate::{
text::text_container::TextContainer,
ContainerID, ContainerType,
},
dag::DagUtils,
id::ClientID,
InternalString, LogStore, VersionVector,
};

View file

@ -184,22 +184,26 @@ impl VersionVector {
let mut ans: VersionVectorDiff = Default::default();
for (client_id, &counter) in self.iter() {
if let Some(&rhs_counter) = rhs.get(client_id) {
if counter > rhs_counter {
ans.left.insert(
*client_id,
CounterSpan {
start: rhs_counter,
end: counter,
},
);
} else if counter < rhs_counter {
ans.right.insert(
*client_id,
CounterSpan {
start: counter,
end: rhs_counter,
},
);
match counter.cmp(&rhs_counter) {
Ordering::Less => {
ans.right.insert(
*client_id,
CounterSpan {
start: counter,
end: rhs_counter,
},
);
}
Ordering::Greater => {
ans.left.insert(
*client_id,
CounterSpan {
start: rhs_counter,
end: counter,
},
);
}
Ordering::Equal => {}
}
} else {
ans.left.insert(

View file

@ -334,6 +334,7 @@ impl<'a, T: Rle, A: RleTreeTrait<T>> InternalNode<'a, T, A> {
};
if result.is_err() && self.is_root() {
#[allow(clippy::unnecessary_unwrap)]
let new_vec = result.unwrap_err();
{
// create level

View file

@ -250,7 +250,7 @@ impl<'a, T: HasLength> Iterator for SliceIterator<'a, T> {
let end_index = self.end_index.unwrap_or(self.vec.len() - 1);
if self.cur_index == end_index {
let elem = &self.vec[self.cur_index];
let end = self.end_offset.unwrap_or(elem.len());
let end = self.end_offset.unwrap_or_else(|| elem.len());
if self.cur_offset == end {
return None;
}