Fix lints
This commit is contained in:
parent
3da0673af6
commit
450eaaff05
5 changed files with 29 additions and 16 deletions
|
|
@ -3,9 +3,8 @@
|
|||
set -e
|
||||
|
||||
wasm-pack build --target web --features wasm
|
||||
cargo test --verbose -- --include-ignored
|
||||
cargo test --features serde
|
||||
cargo test --features wasm
|
||||
cargo test --verbose --features serde -- --include-ignored
|
||||
cargo test --features serde,wasm
|
||||
wasm-pack test --node --features wasm
|
||||
|
||||
cd reconcile-js
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
mod edited_text;
|
||||
mod operation;
|
||||
mod utils;
|
||||
mod transport;
|
||||
mod utils;
|
||||
use std::fmt::Debug;
|
||||
|
||||
|
||||
pub use transport::{ChangeSet};
|
||||
pub use edited_text::EditedText;
|
||||
pub use operation::Operation;
|
||||
pub use edited_text::{EditedText};
|
||||
pub use transport::ChangeSet;
|
||||
|
||||
use crate::{Tokenizer, types::text_with_cursors::TextWithCursors};
|
||||
|
||||
|
|
|
|||
|
|
@ -381,7 +381,6 @@ where
|
|||
mod tests {
|
||||
use insta::assert_debug_snapshot;
|
||||
use pretty_assertions::assert_eq;
|
||||
use serde_yaml;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ use std::fmt::Debug;
|
|||
#[cfg(feature = "serde")]
|
||||
use serde::{
|
||||
Deserialize, Serialize,
|
||||
de::{self, Deserializer, SeqAccess, Visitor},
|
||||
ser::{SerializeSeq, Serializer},
|
||||
de::{self, Deserializer, Visitor},
|
||||
ser::Serializer,
|
||||
};
|
||||
|
||||
use crate::{CursorPosition, Tokenizer, operation_transformation::Operation};
|
||||
|
|
@ -126,7 +126,9 @@ impl Serialize for SimpleOperation {
|
|||
match self {
|
||||
SimpleOperation::Equal { length } => serializer.serialize_u64(*length as u64),
|
||||
SimpleOperation::Insert { text } => serializer.serialize_str(text),
|
||||
SimpleOperation::Delete { length } => serializer.serialize_i64(-(*length as i64)),
|
||||
SimpleOperation::Delete { length } => {
|
||||
serializer.serialize_i64(-(i64::try_from(*length).unwrap_or(i64::MAX)))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -137,12 +139,14 @@ impl<'de> Deserialize<'de> for SimpleOperation {
|
|||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
use std::fmt;
|
||||
|
||||
struct OperationVisitor;
|
||||
|
||||
impl<'de> Visitor<'de> for OperationVisitor {
|
||||
impl Visitor<'_> for OperationVisitor {
|
||||
type Value = SimpleOperation;
|
||||
|
||||
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
formatter.write_str("an integer between -2^64 and 2^63 or a string")
|
||||
}
|
||||
|
||||
|
|
@ -151,7 +155,7 @@ impl<'de> Deserialize<'de> for SimpleOperation {
|
|||
E: de::Error,
|
||||
{
|
||||
Ok(SimpleOperation::Equal {
|
||||
length: value as usize,
|
||||
length: usize::try_from(value).unwrap_or(usize::MAX),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -160,7 +164,7 @@ impl<'de> Deserialize<'de> for SimpleOperation {
|
|||
E: de::Error,
|
||||
{
|
||||
Ok(SimpleOperation::Delete {
|
||||
length: (-value) as usize,
|
||||
length: usize::try_from(-value).unwrap_or(usize::MAX),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use std::iter::Iterator;
|
||||
use std::{fmt, iter::Iterator};
|
||||
|
||||
/// A helper for building a string in-order based on an original string and a
|
||||
/// series of insertions, deletions, and copies applied to it. It is safe to use
|
||||
|
|
@ -12,6 +12,18 @@ pub struct StringBuilder<'a> {
|
|||
remaining: String,
|
||||
}
|
||||
|
||||
impl fmt::Debug for StringBuilder<'_> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let mut debug_struct = f.debug_struct("StringBuilder");
|
||||
debug_struct.field("buffer", &self.buffer);
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
debug_struct.field("remaining", &self.remaining);
|
||||
|
||||
debug_struct.finish_non_exhaustive()
|
||||
}
|
||||
}
|
||||
|
||||
impl StringBuilder<'_> {
|
||||
pub fn new(original: &str) -> StringBuilder<'_> {
|
||||
StringBuilder {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue