Skip to content

Commit

Permalink
Change dyn.d_val() and dyn.d_ptr() to take self by ref
Browse files Browse the repository at this point in the history
As pointed out in #34, there's no need to move/consume self when calling these methods - they're intended as data getter methods.
  • Loading branch information
cole14 committed Oct 28, 2023
1 parent 964d4ab commit 66179d3
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/dynamic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ pub struct Dyn {
}

impl Dyn {
pub fn d_val(self) -> u64 {
pub fn d_val(&self) -> u64 {
self.d_un
}

pub fn d_ptr(self) -> u64 {
pub fn d_ptr(&self) -> u64 {
self.d_un
}
}
Expand Down Expand Up @@ -77,6 +77,16 @@ mod parse_tests {
use crate::endian::{BigEndian, LittleEndian};
use crate::parse::{test_parse_for, test_parse_fuzz_too_short};

#[test]
fn test_d_val_and_d_ptr() {
let val = Dyn {
d_tag: 0x01,
d_un: 0x0102030405060708,
};
assert_eq!(val.d_ptr(), 0x0102030405060708);
assert_eq!(val.d_val(), 0x0102030405060708);
}

#[test]
fn parse_dyn32_lsb() {
test_parse_for(
Expand Down

0 comments on commit 66179d3

Please sign in to comment.