diff --git a/taskchampion/lib/src/string.rs b/taskchampion/lib/src/string.rs index de090116b..36db8a4ac 100644 --- a/taskchampion/lib/src/string.rs +++ b/taskchampion/lib/src/string.rs @@ -104,7 +104,7 @@ impl TCString { } } -#[derive(PartialEq, Debug)] +#[derive(PartialEq, Eq, Debug)] pub enum RustString<'a> { Null, CString(CString), @@ -600,7 +600,7 @@ mod test { fn make_cstr() -> RustString<'static> { let cstr = CStr::from_bytes_with_nul(b"a string\0").unwrap(); - RustString::CStr(&cstr) + RustString::CStr(cstr) } fn make_string() -> RustString<'static> { diff --git a/taskchampion/sync-server/src/server.rs b/taskchampion/sync-server/src/server.rs index 2311d98eb..8dc2c8ab5 100644 --- a/taskchampion/sync-server/src/server.rs +++ b/taskchampion/sync-server/src/server.rs @@ -38,8 +38,8 @@ impl Default for ServerConfig { impl ServerConfig { pub fn from_args(snapshot_days: i64, snapshot_versions: u32) -> anyhow::Result { Ok(ServerConfig { - snapshot_days: snapshot_days, - snapshot_versions: snapshot_versions, + snapshot_days, + snapshot_versions, }) } } @@ -1021,7 +1021,7 @@ mod test { let client = txn.get_client(client_key)?.unwrap(); assert_eq!( get_snapshot(txn, &ServerConfig::default(), client_key, client)?, - Some((snapshot_version_id, data.clone())) + Some((snapshot_version_id, data)) ); Ok(()) diff --git a/taskchampion/sync-server/src/storage/mod.rs b/taskchampion/sync-server/src/storage/mod.rs index c52624898..2a7711b7f 100644 --- a/taskchampion/sync-server/src/storage/mod.rs +++ b/taskchampion/sync-server/src/storage/mod.rs @@ -10,7 +10,7 @@ pub use inmemory::InMemoryStorage; mod sqlite; pub use self::sqlite::SqliteStorage; -#[derive(Clone, PartialEq, Debug)] +#[derive(Clone, PartialEq, Eq, Debug)] pub struct Client { /// The latest version for this client (may be the nil version) pub latest_version_id: Uuid, @@ -18,7 +18,7 @@ pub struct Client { pub snapshot: Option, } -#[derive(Clone, PartialEq, Debug)] +#[derive(Clone, PartialEq, Eq, Debug)] pub struct Snapshot { /// ID of the version at which this snapshot was made pub version_id: Uuid, @@ -30,7 +30,7 @@ pub struct Snapshot { pub versions_since: u32, } -#[derive(Clone, PartialEq, Debug)] +#[derive(Clone, PartialEq, Eq, Debug)] pub struct Version { pub version_id: Uuid, pub parent_version_id: Uuid, diff --git a/taskchampion/taskchampion/src/depmap.rs b/taskchampion/taskchampion/src/depmap.rs index d2f6225bf..fe4d5df6f 100644 --- a/taskchampion/taskchampion/src/depmap.rs +++ b/taskchampion/taskchampion/src/depmap.rs @@ -4,7 +4,7 @@ use uuid::Uuid; /// /// This information requires a scan of the working set to generate, so it is /// typically calculated once and re-used. -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub struct DependencyMap { /// Edges of the dependency graph. If (a, b) is in this array, then task a depends on tsak b. edges: Vec<(Uuid, Uuid)>, diff --git a/taskchampion/taskchampion/src/server/crypto.rs b/taskchampion/taskchampion/src/server/crypto.rs index 978a38fd8..9a34f6575 100644 --- a/taskchampion/taskchampion/src/server/crypto.rs +++ b/taskchampion/taskchampion/src/server/crypto.rs @@ -271,7 +271,7 @@ mod test { let unsealed = Unsealed { version_id, - payload: payload.clone(), + payload: payload, }; let sealed = cryptor.seal(unsealed).unwrap(); @@ -291,7 +291,7 @@ mod test { let unsealed = Unsealed { version_id, - payload: payload.clone(), + payload: payload, }; let mut sealed = cryptor.seal(unsealed).unwrap(); sealed.version_id = Uuid::new_v4(); // change the version_id @@ -309,7 +309,7 @@ mod test { let unsealed = Unsealed { version_id, - payload: payload.clone(), + payload: payload, }; let sealed = cryptor.seal(unsealed).unwrap(); diff --git a/taskchampion/taskchampion/src/server/local.rs b/taskchampion/taskchampion/src/server/local.rs index 37cb06614..f50297bf6 100644 --- a/taskchampion/taskchampion/src/server/local.rs +++ b/taskchampion/taskchampion/src/server/local.rs @@ -250,7 +250,7 @@ mod test { // then add another, not based on that one if let (AddVersionResult::Ok(_), SnapshotUrgency::None) = - server.add_version(parent_version_id, history.clone())? + server.add_version(parent_version_id, history)? { panic!("should not have accepted the version") } diff --git a/taskchampion/taskchampion/src/server/op.rs b/taskchampion/taskchampion/src/server/op.rs index c2906700f..ff145dd44 100644 --- a/taskchampion/taskchampion/src/server/op.rs +++ b/taskchampion/taskchampion/src/server/op.rs @@ -4,7 +4,7 @@ use uuid::Uuid; /// A SyncOp defines a single change to the task database, that can be synchronized /// via a server. -#[derive(PartialEq, Clone, Debug, Serialize, Deserialize)] +#[derive(PartialEq, Eq, Clone, Debug, Serialize, Deserialize)] pub enum SyncOp { /// Create a new task. /// diff --git a/taskchampion/taskchampion/src/server/types.rs b/taskchampion/taskchampion/src/server/types.rs index fada6c04a..5a938f984 100644 --- a/taskchampion/taskchampion/src/server/types.rs +++ b/taskchampion/taskchampion/src/server/types.rs @@ -15,7 +15,7 @@ pub type HistorySegment = Vec; pub type Snapshot = Vec; /// AddVersionResult is the response type from [`crate::server::Server::add_version`]. -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub enum AddVersionResult { /// OK, version added with the given ID Ok(VersionId), @@ -35,7 +35,7 @@ pub enum SnapshotUrgency { } /// A version as downloaded from the server -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub enum GetVersionResult { /// No such version exists NoSuchVersion, diff --git a/taskchampion/taskchampion/src/storage/op.rs b/taskchampion/taskchampion/src/storage/op.rs index a742238bc..1a65f1aee 100644 --- a/taskchampion/taskchampion/src/storage/op.rs +++ b/taskchampion/taskchampion/src/storage/op.rs @@ -6,7 +6,7 @@ use uuid::Uuid; /// A ReplicaOp defines a single change to the task database, as stored locally in the replica. /// This contains additional information not included in SyncOp. -#[derive(PartialEq, Clone, Debug, Serialize, Deserialize)] +#[derive(PartialEq, Eq, Clone, Debug, Serialize, Deserialize)] pub enum ReplicaOp { /// Create a new task. /// diff --git a/taskchampion/taskchampion/src/storage/sqlite.rs b/taskchampion/taskchampion/src/storage/sqlite.rs index 7e30931a4..88d2ae676 100644 --- a/taskchampion/taskchampion/src/storage/sqlite.rs +++ b/taskchampion/taskchampion/src/storage/sqlite.rs @@ -532,14 +532,14 @@ mod test { let uuid2 = Uuid::new_v4(); { let mut txn = storage.txn()?; - assert!(txn.create_task(uuid1.clone())?); + assert!(txn.create_task(uuid1)?); txn.set_task( - uuid1.clone(), + uuid1, taskmap_with(vec![("num".to_string(), "1".to_string())]), )?; - assert!(txn.create_task(uuid2.clone())?); + assert!(txn.create_task(uuid2)?); txn.set_task( - uuid2.clone(), + uuid2, taskmap_with(vec![("num".to_string(), "2".to_string())]), )?; txn.commit()?; @@ -553,11 +553,11 @@ mod test { let mut exp = vec![ ( - uuid1.clone(), + uuid1, taskmap_with(vec![("num".to_string(), "1".to_string())]), ), ( - uuid2.clone(), + uuid2, taskmap_with(vec![("num".to_string(), "2".to_string())]), ), ]; @@ -570,7 +570,7 @@ mod test { let mut uuids = txn.all_task_uuids()?; uuids.sort(); - let mut exp = vec![uuid1.clone(), uuid2.clone()]; + let mut exp = vec![uuid1, uuid2]; exp.sort(); assert_eq!(uuids, exp); diff --git a/taskchampion/taskchampion/src/task/status.rs b/taskchampion/taskchampion/src/task/status.rs index 31fee9cf7..55ccbb4c1 100644 --- a/taskchampion/taskchampion/src/task/status.rs +++ b/taskchampion/taskchampion/src/task/status.rs @@ -1,5 +1,5 @@ /// The status of a task, as defined by the task data model. -#[derive(Debug, PartialEq, Clone, strum_macros::Display)] +#[derive(Debug, PartialEq, Eq, Clone, strum_macros::Display)] #[repr(C)] pub enum Status { Pending, diff --git a/taskchampion/taskchampion/src/task/task.rs b/taskchampion/taskchampion/src/task/task.rs index 55c5c6318..f742afdcb 100644 --- a/taskchampion/taskchampion/src/task/task.rs +++ b/taskchampion/taskchampion/src/task/task.rs @@ -887,7 +887,7 @@ mod test { with_mut_task(|mut task| { let property = "property-name"; task.set_value(property, Some("value".into())).unwrap(); - assert_eq!(task.get_value(property), Some("value".into())); + assert_eq!(task.get_value(property), Some("value")); task.set_value(property, None).unwrap(); assert_eq!(task.get_value(property), None); }); diff --git a/taskchampion/taskchampion/src/taskdb/apply.rs b/taskchampion/taskchampion/src/taskdb/apply.rs index 1e3a3fa83..24f7113a3 100644 --- a/taskchampion/taskchampion/src/taskdb/apply.rs +++ b/taskchampion/taskchampion/src/taskdb/apply.rs @@ -148,7 +148,7 @@ mod tests { let op = SyncOp::Create { uuid }; { let mut txn = db.storage.txn()?; - let taskmap = apply_and_record(txn.as_mut(), op.clone())?; + let taskmap = apply_and_record(txn.as_mut(), op)?; assert_eq!(taskmap.len(), 1); assert_eq!(taskmap.get("foo").unwrap(), "bar"); diff --git a/taskchampion/taskchampion/src/taskdb/mod.rs b/taskchampion/taskchampion/src/taskdb/mod.rs index 697827795..ee1fcc0ad 100644 --- a/taskchampion/taskchampion/src/taskdb/mod.rs +++ b/taskchampion/taskchampion/src/taskdb/mod.rs @@ -163,7 +163,7 @@ impl TaskDb { .map(|(p, v)| (p.clone(), v.clone())) .collect::>(); t.sort(); - (u.clone(), t) + (*u, t) }) .collect(); res.sort(); @@ -175,8 +175,7 @@ impl TaskDb { let mut txn = self.storage.txn().unwrap(); txn.operations() .unwrap() - .iter() - .map(|o| o.clone()) + .iter().cloned() .collect() } } @@ -198,7 +197,7 @@ mod tests { let mut db = TaskDb::new_inmemory(); let uuid = Uuid::new_v4(); let op = SyncOp::Create { uuid }; - db.apply(op.clone()).unwrap(); + db.apply(op).unwrap(); assert_eq!(db.sorted_tasks(), vec![(uuid, vec![]),]); assert_eq!(db.operations(), vec![ReplicaOp::Create { uuid }]); diff --git a/taskchampion/taskchampion/src/taskdb/working_set.rs b/taskchampion/taskchampion/src/taskdb/working_set.rs index dd9e57f97..d6ae3c9fd 100644 --- a/taskchampion/taskchampion/src/taskdb/working_set.rs +++ b/taskchampion/taskchampion/src/taskdb/working_set.rs @@ -98,7 +98,7 @@ mod test { } for i in &[0usize, 1, 4] { db.apply(SyncOp::Update { - uuid: uuids[*i].clone(), + uuid: uuids[*i], property: String::from("status"), value: Some("pending".into()), timestamp: Utc::now(), @@ -121,9 +121,9 @@ mod test { db.working_set()?, vec![ None, - Some(uuids[1].clone()), - Some(uuids[3].clone()), - Some(uuids[4].clone()) + Some(uuids[1]), + Some(uuids[3]), + Some(uuids[4]) ] ); @@ -144,19 +144,19 @@ mod test { // to the top, and then uuids[0] is added. vec![ None, - Some(uuids[1].clone()), - Some(uuids[4].clone()), - Some(uuids[0].clone()), + Some(uuids[1]), + Some(uuids[4]), + Some(uuids[0]), ] } else { // uuids[1] and uuids[4] are already in the working set, at indexes 1 and 3, // and then uuids[0] is added. vec![ None, - Some(uuids[1].clone()), + Some(uuids[1]), None, - Some(uuids[4].clone()), - Some(uuids[0].clone()), + Some(uuids[4]), + Some(uuids[0]), ] };