fix clippy lints

This commit is contained in:
Dustin J. Mitchell 2022-10-02 19:01:48 +00:00
parent 9e6be07e24
commit 1b55e5b265
15 changed files with 40 additions and 41 deletions

View file

@ -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> {

View file

@ -38,8 +38,8 @@ impl Default for ServerConfig {
impl ServerConfig {
pub fn from_args(snapshot_days: i64, snapshot_versions: u32) -> anyhow::Result<ServerConfig> {
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(())

View file

@ -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<Snapshot>,
}
#[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,

View file

@ -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)>,

View file

@ -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();

View file

@ -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")
}

View file

@ -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.
///

View file

@ -15,7 +15,7 @@ pub type HistorySegment = Vec<u8>;
pub type Snapshot = Vec<u8>;
/// 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,

View file

@ -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.
///

View file

@ -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);

View file

@ -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,

View file

@ -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);
});

View file

@ -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");

View file

@ -163,7 +163,7 @@ impl TaskDb {
.map(|(p, v)| (p.clone(), v.clone()))
.collect::<Vec<(String, String)>>();
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 }]);

View file

@ -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]),
]
};