cleanup: replace some as_slice() by &

This commit is contained in:
Martin von Zweigbergk 2021-11-10 10:46:10 -08:00
parent e5dd93cbf7
commit ced252f766
5 changed files with 7 additions and 7 deletions

View file

@ -164,9 +164,9 @@ pub fn materialize_conflict(
.collect_vec();
let removed_slices = removed_content
.iter()
.map(|vec| vec.as_slice())
.map(Vec::as_slice)
.collect_vec();
let added_slices = added_content.iter().map(|vec| vec.as_slice()).collect_vec();
let added_slices = added_content.iter().map(Vec::as_slice).collect_vec();
let merge_result = files::merge(&removed_slices, &added_slices);
match merge_result {

View file

@ -222,7 +222,7 @@ impl Backend for GitBackend {
let mut bytes = Vec::new();
contents.read_to_end(&mut bytes).unwrap();
let locked_repo = self.repo.lock().unwrap();
let oid = locked_repo.blob(bytes.as_slice()).unwrap();
let oid = locked_repo.blob(&bytes).unwrap();
Ok(FileId::new(oid.as_bytes().to_vec()))
}
@ -428,7 +428,7 @@ impl Backend for GitBackend {
.unwrap()
.start_modification();
if let Some(existing_extras) = mut_table.get_value(git_id.as_bytes()) {
if existing_extras != extras.as_slice() {
if existing_extras != &extras {
return Err(BackendError::Other(format!(
"Git commit '{}' already exists with different associated non-Git meta-data",
id.hex()

View file

@ -177,7 +177,7 @@ impl<'table> ReadonlyTableIndexEntry<'table> {
fn new(table: &'table ReadonlyTable, pos: usize) -> Self {
let entry_size = ReadonlyTableIndexEntry::size(table.key_size);
let offset = entry_size * pos;
let data = &table.index.as_slice()[offset..offset + entry_size];
let data = &table.index[offset..offset + entry_size];
ReadonlyTableIndexEntry { data }
}

View file

@ -630,7 +630,7 @@ fn test_simplify_conflict_after_resolving_parent(use_git: bool) {
executable: false,
}) => {
assert_eq!(
testutils::read_file(repo.store(), &path, &id).as_slice(),
testutils::read_file(repo.store(), &path, &id),
b"AbC\ndef\nGhi\n"
);
}

View file

@ -31,7 +31,7 @@ pub trait Formatter: Write {
fn write_from_reader(&mut self, reader: &mut dyn Read) -> io::Result<()> {
let mut buffer = vec![];
reader.read_to_end(&mut buffer).unwrap();
self.write_all(buffer.as_slice())
self.write_all(&buffer)
}
fn add_label(&mut self, label: String) -> io::Result<()>;