Skip to content

Commit

Permalink
fix some clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
Dushistov committed Jul 17, 2024
1 parent 5b376d6 commit ce9bbe0
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 30 deletions.
2 changes: 1 addition & 1 deletion couchbase-lite/src/doc_enumerator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub struct DocumentInfo<'a, 'b> {
phantom: PhantomData<&'a DocEnumerator<'b>>,
}

impl<'a, 'b> DocumentInfo<'_, '_> {
impl DocumentInfo<'_, '_> {
pub(crate) fn new(inner: C4DocumentInfo) -> Self {
Self {
inner,
Expand Down
7 changes: 1 addition & 6 deletions couchbase-lite/src/replicator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,7 @@ impl Replicator {
!ctx.is_null(),
"Replicator::call_on_status_changed: Internal error - null function pointer"
);
match ReplicatorState::try_from(status) {
Ok(state) => ((*ctx).state_cb)(state),
Err(err) => {
error!("replicator status change: invalid status {err}");
}
}
((*ctx).state_cb)(ReplicatorState::from(status));
});
if r.is_err() {
error!("Replicator::call_on_status_changed: catch panic aborting");
Expand Down
8 changes: 3 additions & 5 deletions couchbase-lite/src/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,10 @@ impl ValueRef<'_> {
ValueRef::UnsignedInt(FLValue_AsUnsigned(value))
} else if FLValue_IsInteger(value) {
ValueRef::SignedInt(FLValue_AsInt(value))
} else if FLValue_IsDouble(value) {
ValueRef::Double(FLValue_AsDouble(value))
} else {
if FLValue_IsDouble(value) {
ValueRef::Double(FLValue_AsDouble(value))
} else {
ValueRef::Float(FLValue_AsFloat(value))
}
ValueRef::Float(FLValue_AsFloat(value))
}
}
kFLString => {
Expand Down
8 changes: 4 additions & 4 deletions examples/chat-demo/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
} else if msg.starts_with("!list") {
db_exec_repl.spawn(move |db| {
if let Some(db) = db.as_mut() {
print_all_messages(&mut db.db).expect("read from db failed");
print_all_messages(&db.db).expect("read from db failed");
}
});
} else {
Expand All @@ -103,7 +103,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let edit_id = edit_id.take();
db_exec_repl.spawn(move |db| {
if let Some(db) = db.as_mut() {
save_msg(&mut db.db, &msg, edit_id.as_ref().map(String::as_str))
save_msg(&mut db.db, &msg, edit_id.as_deref())
.expect("save to db failed");
} else {
eprintln!("db is NOT open");
Expand Down Expand Up @@ -150,7 +150,7 @@ fn fix_conflicts(db: &mut Database) -> Result<(), Box<dyn std::error::Error>> {
println!("There are {} conflicts in database", conflicts.len());

for doc_id in &conflicts {
resolve_conflict(db, &doc_id)?;
resolve_conflict(db, doc_id)?;
}
if !conflicts.is_empty() {
println!("All conflicts was resolved");
Expand Down Expand Up @@ -316,7 +316,7 @@ fn print_all_messages(db: &Database) -> Result<(), Box<dyn std::error::Error>> {
fn print_external_changes(mdb: &mut Option<MyDb>) -> Result<(), Box<dyn std::error::Error>> {
let mdb = mdb
.as_mut()
.ok_or_else(|| format!("print_external_changes: db not OPEN"))?;
.ok_or_else(|| "print_external_changes: db not OPEN")?;
let mut doc_ids = HashSet::<String>::new();
let db = &mut mdb.db;
for change in db.observed_changes() {
Expand Down
16 changes: 8 additions & 8 deletions serde-fleece/src/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,9 @@ impl<'a> ser::Serializer for &'a mut Serializer {
encoder_write!(self, FLEncoder_WriteNull)
}
#[inline]
fn serialize_some<T: ?Sized>(self, value: &T) -> Result<Self::Ok, Self::Error>
fn serialize_some<T>(self, value: &T) -> Result<Self::Ok, Self::Error>
where
T: Serialize,
T: ?Sized + Serialize,
{
value.serialize(&mut *self)
}
Expand All @@ -215,26 +215,26 @@ impl<'a> ser::Serializer for &'a mut Serializer {
encoder_write!(self, FLEncoder_WriteString, variant.into())
}
#[inline]
fn serialize_newtype_struct<T: ?Sized>(
fn serialize_newtype_struct<T>(
self,
_name: &'static str,
value: &T,
) -> Result<Self::Ok, Self::Error>
where
T: Serialize,
T: ?Sized + Serialize,
{
value.serialize(&mut *self)
}
#[inline]
fn serialize_newtype_variant<T: ?Sized>(
fn serialize_newtype_variant<T>(
self,
_name: &'static str,
_variant_index: u32,
variant: &'static str,
value: &T,
) -> Result<Self::Ok, Self::Error>
where
T: Serialize,
T: ?Sized + Serialize,
{
encoder_write!(self, FLEncoder_BeginDict, 1)?;
encoder_write!(self, FLEncoder_WriteKey, variant.into())?;
Expand Down Expand Up @@ -301,9 +301,9 @@ impl<'a> ser::Serializer for &'a mut Serializer {
Ok(self)
}
#[inline]
fn collect_str<T: ?Sized>(self, value: &T) -> Result<Self::Ok, Self::Error>
fn collect_str<T>(self, value: &T) -> Result<Self::Ok, Self::Error>
where
T: Display,
T: ?Sized + Display,
{
self.serialize_str(&value.to_string())
}
Expand Down
12 changes: 6 additions & 6 deletions serde-fleece/src/ser/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ where
Err(Error::Unsupported("key must be a string (none)"))
}

fn serialize_some<T: ?Sized>(self, _value: &T) -> Result<Self::Ok, Self::Error>
fn serialize_some<T>(self, _value: &T) -> Result<Self::Ok, Self::Error>
where
T: Serialize,
T: ?Sized + Serialize,
{
Err(Error::Unsupported("key must be a string (some)"))
}
Expand All @@ -117,26 +117,26 @@ where
encoder_write!(self.ser, FLEncoder_WriteKey, variant.into())
}

fn serialize_newtype_struct<T: ?Sized>(
fn serialize_newtype_struct<T>(
self,
_name: &'static str,
value: &T,
) -> Result<Self::Ok, Self::Error>
where
T: Serialize,
T: ?Sized + Serialize,
{
value.serialize(&mut *self)
}

fn serialize_newtype_variant<T: ?Sized>(
fn serialize_newtype_variant<T>(
self,
_name: &'static str,
_variant_index: u32,
_variant: &'static str,
_value: &T,
) -> Result<Self::Ok, Self::Error>
where
T: Serialize,
T: ?Sized + Serialize,
{
Err(Error::Unsupported("key must be a string (newtype variant)"))
}
Expand Down

0 comments on commit ce9bbe0

Please sign in to comment.