Skip to content

Commit ce9bbe0

Browse files
committed
fix some clippy lints
1 parent 5b376d6 commit ce9bbe0

File tree

6 files changed

+23
-30
lines changed

6 files changed

+23
-30
lines changed

couchbase-lite/src/doc_enumerator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub struct DocumentInfo<'a, 'b> {
2929
phantom: PhantomData<&'a DocEnumerator<'b>>,
3030
}
3131

32-
impl<'a, 'b> DocumentInfo<'_, '_> {
32+
impl DocumentInfo<'_, '_> {
3333
pub(crate) fn new(inner: C4DocumentInfo) -> Self {
3434
Self {
3535
inner,

couchbase-lite/src/replicator.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -260,12 +260,7 @@ impl Replicator {
260260
!ctx.is_null(),
261261
"Replicator::call_on_status_changed: Internal error - null function pointer"
262262
);
263-
match ReplicatorState::try_from(status) {
264-
Ok(state) => ((*ctx).state_cb)(state),
265-
Err(err) => {
266-
error!("replicator status change: invalid status {err}");
267-
}
268-
}
263+
((*ctx).state_cb)(ReplicatorState::from(status));
269264
});
270265
if r.is_err() {
271266
error!("Replicator::call_on_status_changed: catch panic aborting");

couchbase-lite/src/value.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,10 @@ impl ValueRef<'_> {
6565
ValueRef::UnsignedInt(FLValue_AsUnsigned(value))
6666
} else if FLValue_IsInteger(value) {
6767
ValueRef::SignedInt(FLValue_AsInt(value))
68+
} else if FLValue_IsDouble(value) {
69+
ValueRef::Double(FLValue_AsDouble(value))
6870
} else {
69-
if FLValue_IsDouble(value) {
70-
ValueRef::Double(FLValue_AsDouble(value))
71-
} else {
72-
ValueRef::Float(FLValue_AsFloat(value))
73-
}
71+
ValueRef::Float(FLValue_AsFloat(value))
7472
}
7573
}
7674
kFLString => {

examples/chat-demo/src/main.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
9292
} else if msg.starts_with("!list") {
9393
db_exec_repl.spawn(move |db| {
9494
if let Some(db) = db.as_mut() {
95-
print_all_messages(&mut db.db).expect("read from db failed");
95+
print_all_messages(&db.db).expect("read from db failed");
9696
}
9797
});
9898
} else {
@@ -103,7 +103,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
103103
let edit_id = edit_id.take();
104104
db_exec_repl.spawn(move |db| {
105105
if let Some(db) = db.as_mut() {
106-
save_msg(&mut db.db, &msg, edit_id.as_ref().map(String::as_str))
106+
save_msg(&mut db.db, &msg, edit_id.as_deref())
107107
.expect("save to db failed");
108108
} else {
109109
eprintln!("db is NOT open");
@@ -150,7 +150,7 @@ fn fix_conflicts(db: &mut Database) -> Result<(), Box<dyn std::error::Error>> {
150150
println!("There are {} conflicts in database", conflicts.len());
151151

152152
for doc_id in &conflicts {
153-
resolve_conflict(db, &doc_id)?;
153+
resolve_conflict(db, doc_id)?;
154154
}
155155
if !conflicts.is_empty() {
156156
println!("All conflicts was resolved");
@@ -316,7 +316,7 @@ fn print_all_messages(db: &Database) -> Result<(), Box<dyn std::error::Error>> {
316316
fn print_external_changes(mdb: &mut Option<MyDb>) -> Result<(), Box<dyn std::error::Error>> {
317317
let mdb = mdb
318318
.as_mut()
319-
.ok_or_else(|| format!("print_external_changes: db not OPEN"))?;
319+
.ok_or_else(|| "print_external_changes: db not OPEN")?;
320320
let mut doc_ids = HashSet::<String>::new();
321321
let db = &mut mdb.db;
322322
for change in db.observed_changes() {

serde-fleece/src/ser.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,9 @@ impl<'a> ser::Serializer for &'a mut Serializer {
191191
encoder_write!(self, FLEncoder_WriteNull)
192192
}
193193
#[inline]
194-
fn serialize_some<T: ?Sized>(self, value: &T) -> Result<Self::Ok, Self::Error>
194+
fn serialize_some<T>(self, value: &T) -> Result<Self::Ok, Self::Error>
195195
where
196-
T: Serialize,
196+
T: ?Sized + Serialize,
197197
{
198198
value.serialize(&mut *self)
199199
}
@@ -215,26 +215,26 @@ impl<'a> ser::Serializer for &'a mut Serializer {
215215
encoder_write!(self, FLEncoder_WriteString, variant.into())
216216
}
217217
#[inline]
218-
fn serialize_newtype_struct<T: ?Sized>(
218+
fn serialize_newtype_struct<T>(
219219
self,
220220
_name: &'static str,
221221
value: &T,
222222
) -> Result<Self::Ok, Self::Error>
223223
where
224-
T: Serialize,
224+
T: ?Sized + Serialize,
225225
{
226226
value.serialize(&mut *self)
227227
}
228228
#[inline]
229-
fn serialize_newtype_variant<T: ?Sized>(
229+
fn serialize_newtype_variant<T>(
230230
self,
231231
_name: &'static str,
232232
_variant_index: u32,
233233
variant: &'static str,
234234
value: &T,
235235
) -> Result<Self::Ok, Self::Error>
236236
where
237-
T: Serialize,
237+
T: ?Sized + Serialize,
238238
{
239239
encoder_write!(self, FLEncoder_BeginDict, 1)?;
240240
encoder_write!(self, FLEncoder_WriteKey, variant.into())?;
@@ -301,9 +301,9 @@ impl<'a> ser::Serializer for &'a mut Serializer {
301301
Ok(self)
302302
}
303303
#[inline]
304-
fn collect_str<T: ?Sized>(self, value: &T) -> Result<Self::Ok, Self::Error>
304+
fn collect_str<T>(self, value: &T) -> Result<Self::Ok, Self::Error>
305305
where
306-
T: Display,
306+
T: ?Sized + Display,
307307
{
308308
self.serialize_str(&value.to_string())
309309
}

serde-fleece/src/ser/map.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ where
9393
Err(Error::Unsupported("key must be a string (none)"))
9494
}
9595

96-
fn serialize_some<T: ?Sized>(self, _value: &T) -> Result<Self::Ok, Self::Error>
96+
fn serialize_some<T>(self, _value: &T) -> Result<Self::Ok, Self::Error>
9797
where
98-
T: Serialize,
98+
T: ?Sized + Serialize,
9999
{
100100
Err(Error::Unsupported("key must be a string (some)"))
101101
}
@@ -117,26 +117,26 @@ where
117117
encoder_write!(self.ser, FLEncoder_WriteKey, variant.into())
118118
}
119119

120-
fn serialize_newtype_struct<T: ?Sized>(
120+
fn serialize_newtype_struct<T>(
121121
self,
122122
_name: &'static str,
123123
value: &T,
124124
) -> Result<Self::Ok, Self::Error>
125125
where
126-
T: Serialize,
126+
T: ?Sized + Serialize,
127127
{
128128
value.serialize(&mut *self)
129129
}
130130

131-
fn serialize_newtype_variant<T: ?Sized>(
131+
fn serialize_newtype_variant<T>(
132132
self,
133133
_name: &'static str,
134134
_variant_index: u32,
135135
_variant: &'static str,
136136
_value: &T,
137137
) -> Result<Self::Ok, Self::Error>
138138
where
139-
T: Serialize,
139+
T: ?Sized + Serialize,
140140
{
141141
Err(Error::Unsupported("key must be a string (newtype variant)"))
142142
}

0 commit comments

Comments
 (0)