Skip to content

Make Decimal::to_packed_bcd take &self #82

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions dec/src/decimal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ impl<const N: usize> Decimal<N> {
/// (i.e. its negated exponent) or `None` for special values.
///
/// [pd]: http://speleotrove.com/decimal/dnpack.html
pub fn to_packed_bcd(&mut self) -> Option<(Vec<u8>, i32)> {
pub fn to_packed_bcd(&self) -> Option<(Vec<u8>, i32)> {
if self.is_special() {
return None;
}
Expand All @@ -579,7 +579,7 @@ impl<const N: usize> Decimal<N> {
bcd.as_mut_ptr() as *mut u8,
len.try_into().unwrap(),
&mut scale as *mut i32,
self.as_mut_ptr() as *mut decnumber_sys::decNumber,
self.as_ptr() as *const decnumber_sys::decNumber,
)
};
// Null returned only for special values (already handled) or if `self`
Expand Down
2 changes: 1 addition & 1 deletion dec/tests/dec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1983,7 +1983,7 @@ fn decnum_raw_parts_bcd() {
fn inner(s: &str, o: Option<i128>) {
const N: usize = 13;
let mut cx = Context::<Decimal<N>>::default();
let mut d = cx.parse(s).unwrap();
let d = cx.parse(s).unwrap();
let ret = d.to_packed_bcd();
if d.is_special() {
assert!(ret.is_none())
Expand Down
Loading