Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete From and Index trait impls for EndianSlice #669

Merged
merged 1 commit into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/read/cfi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3637,7 +3637,7 @@ mod tests {
.uleb(cie.code_alignment_factor)
.sleb(cie.data_alignment_factor)
.uleb(cie.return_address_register.0.into())
.append_bytes(cie.initial_instructions.into())
.append_bytes(cie.initial_instructions.slice())
.mark(&end);

cie.length = (&end - &start) as usize;
Expand Down Expand Up @@ -3732,7 +3732,7 @@ mod tests {
section
};

let section = section.append_bytes(fde.instructions.into()).mark(&end);
let section = section.append_bytes(fde.instructions.slice()).mark(&end);

fde.length = (&end - &start) as usize;
length.set_const(fde.length as u64);
Expand Down Expand Up @@ -6262,7 +6262,6 @@ mod tests {

section.start().set_const(0);
let section = section.get_contents().unwrap();
let section = EndianSlice::new(&section, LittleEndian);
let eh_frame = kind.section(&section);

// Setup eh_frame_hdr
Expand Down
31 changes: 1 addition & 30 deletions src/read/endian_slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use alloc::borrow::Cow;
#[cfg(feature = "read")]
use alloc::string::String;
use core::ops::{Deref, Index, Range, RangeFrom, RangeTo};
use core::ops::{Deref, Range, RangeFrom, RangeTo};
use core::str;

use crate::endianity::Endianity;
Expand Down Expand Up @@ -167,26 +167,6 @@ where
}
}

impl<'input, Endian> Index<usize> for EndianSlice<'input, Endian>
where
Endian: Endianity,
{
type Output = u8;
fn index(&self, idx: usize) -> &Self::Output {
&self.slice[idx]
}
}

impl<'input, Endian> Index<RangeFrom<usize>> for EndianSlice<'input, Endian>
where
Endian: Endianity,
{
type Output = [u8];
fn index(&self, idx: RangeFrom<usize>) -> &Self::Output {
&self.slice[idx]
}
}

impl<'input, Endian> Deref for EndianSlice<'input, Endian>
where
Endian: Endianity,
Expand All @@ -197,15 +177,6 @@ where
}
}

impl<'input, Endian> From<EndianSlice<'input, Endian>> for &'input [u8]
where
Endian: Endianity,
{
fn from(endian_slice: EndianSlice<'input, Endian>) -> &'input [u8] {
endian_slice.slice
}
}

impl<'input, Endian> Reader for EndianSlice<'input, Endian>
where
Endian: Endianity,
Expand Down
2 changes: 1 addition & 1 deletion src/read/line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2327,7 +2327,7 @@ mod tests {
fn test_parse_unknown_standard_opcode_many_args() {
let input = [OPCODE_BASE, 1, 2, 3];
let input = EndianSlice::new(&input, LittleEndian);
let args = EndianSlice::new(&input[1..], LittleEndian);
let args = input.range_from(1..);
let mut standard_opcode_lengths = Vec::new();
let mut header = make_test_header(input);
standard_opcode_lengths.extend(header.standard_opcode_lengths.slice());
Expand Down
2 changes: 1 addition & 1 deletion src/read/unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3295,7 +3295,7 @@ mod tests {
}
};

let section = section.append_bytes(unit.entries_buf.into()).mark(&end);
let section = section.append_bytes(unit.entries_buf.slice()).mark(&end);

unit.unit_length = (&end - &start) as usize;
length.set_const(unit.unit_length as u64);
Expand Down