Skip to content

Commit fe37535

Browse files
committed
impl Clone for BandId
1 parent be4af0c commit fe37535

File tree

9 files changed

+12
-12
lines changed

9 files changed

+12
-12
lines changed

src/archive.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ impl Archive {
150150
match band_selection {
151151
BandSelectionPolicy::LatestClosed => self
152152
.last_complete_band()?
153-
.map(|band| band.id().clone())
153+
.map(|band| *band.id())
154154
.ok_or(anyhow!("Archive has no complete bands")),
155155
BandSelectionPolicy::Specified(band_id) => Ok(band_id),
156156
BandSelectionPolicy::Latest => self.last_band_id()?.ok_or(anyhow!("Archive is empty")),
@@ -392,7 +392,7 @@ impl Archive {
392392
..
393393
}) => {
394394
if let Ok(band_id) = name.parse::<BandId>() {
395-
if !seen_bands.insert(band_id.clone()) {
395+
if !seen_bands.insert(band_id) {
396396
// TODO: Test this
397397
error!(%band_id, "Duplicated band directory");
398398
}

src/band.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ impl Band {
261261
.transpose()
262262
.context("invalid end timestamp {tail.end_time:?}")?;
263263
Ok(Info {
264-
id: self.band_id.clone(),
264+
id: self.band_id,
265265
is_closed: tail_option.is_some(),
266266
start_time,
267267
end_time,

src/bandid.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use serde::Serialize;
2121
use crate::errors::Error;
2222

2323
/// Identifier for a band within an archive, eg 'b0001'.
24-
#[derive(Debug, PartialEq, Clone, Eq, PartialOrd, Ord, Hash, Serialize)]
24+
#[derive(Debug, PartialEq, Clone, Copy, Eq, PartialOrd, Ord, Hash, Serialize)]
2525
pub struct BandId(u32);
2626

2727
impl BandId {

src/bin/conserve.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ fn stored_tree_from_opt(
542542

543543
fn band_selection_policy_from_opt(backup: &Option<BandId>) -> BandSelectionPolicy {
544544
if let Some(band_id) = backup {
545-
BandSelectionPolicy::Specified(band_id.clone())
545+
BandSelectionPolicy::Specified(*band_id)
546546
} else {
547547
BandSelectionPolicy::Latest
548548
}

src/gc_lock.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl GarbageCollectionLock {
5757
pub fn new(archive: &Archive) -> anyhow::Result<GarbageCollectionLock> {
5858
let archive = archive.clone();
5959
let band_id = archive.last_band_id()?;
60-
if let Some(band_id) = band_id.clone() {
60+
if let Some(band_id) = band_id {
6161
if !archive.band_is_closed(&band_id)? {
6262
bail!("Can't delete blocks because the last band ({band_id}) is incomplete and may be in use" );
6363
}

src/show.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ pub fn show_versions(
108108
if options.tree_size {
109109
let tree_mb_str = crate::misc::bytes_to_human_mb(
110110
archive
111-
.open_stored_tree(BandSelectionPolicy::Specified(band_id.clone()))?
111+
.open_stored_tree(BandSelectionPolicy::Specified(band_id))?
112112
.size(Exclude::nothing())?
113113
.file_bytes,
114114
);

src/stitch.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ impl Iterator for IterStitchedIndexHunks {
132132
}
133133

134134
fn previous_existing_band(archive: &Archive, band_id: &BandId) -> Option<BandId> {
135-
let mut band_id = band_id.clone();
135+
let mut band_id = *band_id;
136136
loop {
137137
// TODO: It might be faster to list the present bands and calculate
138138
// from that, rather than walking backwards one at a time...
@@ -166,7 +166,7 @@ mod test {
166166
}
167167

168168
fn simple_ls(archive: &Archive, band_id: &BandId) -> String {
169-
let strs: Vec<String> = IterStitchedIndexHunks::new(archive, Some(band_id.clone()))
169+
let strs: Vec<String> = IterStitchedIndexHunks::new(archive, Some(*band_id))
170170
.flatten()
171171
.map(|entry| format!("{}:{}", &entry.apath, entry.target.unwrap()))
172172
.collect();
@@ -282,7 +282,7 @@ mod test {
282282

283283
let band_id = band_ids.first().expect("expected at least one band");
284284

285-
let mut iter = IterStitchedIndexHunks::new(&af, Some(band_id.clone()));
285+
let mut iter = IterStitchedIndexHunks::new(&af, Some(*band_id));
286286
// Get the first and only index entry.
287287
// `index_hunks` and `band_id` should be `Some`.
288288
assert!(iter.next().is_some());

src/stored_tree.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl ReadTree for StoredTree {
6363
// TODO: Should return an iter of Result<Entry> so that we can inspect them...
6464
fn iter_entries(&self, subtree: Apath, exclude: Exclude) -> anyhow::Result<Self::IT> {
6565
Ok(
66-
IterStitchedIndexHunks::new(&self.archive, Some(self.band.id().clone()))
66+
IterStitchedIndexHunks::new(&self.archive, Some(*self.band.id()))
6767
.iter_entries(subtree, exclude),
6868
)
6969
}

src/validate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub(crate) fn validate_bands(
5454
continue 'band;
5555
};
5656
if let Err(err) = archive
57-
.open_stored_tree(BandSelectionPolicy::Specified(band_id.clone()))
57+
.open_stored_tree(BandSelectionPolicy::Specified(*band_id))
5858
.and_then(|st| validate_stored_tree(&st))
5959
.map(|st_block_lens| merge_block_lens(&mut block_lens, &st_block_lens))
6060
{

0 commit comments

Comments
 (0)