Skip to content

Commit 47d9b3c

Browse files
committed
make 1.79.0 compatible
1 parent 00435ea commit 47d9b3c

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

core/src/instructions/withdraw_v2.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,12 @@ pub struct WithdrawV2IxData([u8; WITHDRAW_V2_IX_DATA_LEN]);
129129
impl WithdrawV2IxData {
130130
#[inline]
131131
pub const fn new(amount: u64, validator_index: u32) -> Self {
132-
let mut res = [0u8; WITHDRAW_V2_IX_DATA_LEN];
133-
const_assign_byte_arr::<WITHDRAW_V2_IX_DATA_LEN, 0, 1>(&mut res, [WITHDRAW_V2_IX_DISCM]);
134-
const_assign_byte_arr::<WITHDRAW_V2_IX_DATA_LEN, 1, 8>(&mut res, amount.to_le_bytes());
135-
const_assign_byte_arr::<WITHDRAW_V2_IX_DATA_LEN, 9, 4>(
136-
&mut res,
132+
let res = [0u8; WITHDRAW_V2_IX_DATA_LEN];
133+
let res =
134+
const_assign_byte_arr::<WITHDRAW_V2_IX_DATA_LEN, 0, 1>(res, [WITHDRAW_V2_IX_DISCM]);
135+
let res = const_assign_byte_arr::<WITHDRAW_V2_IX_DATA_LEN, 1, 8>(res, amount.to_le_bytes());
136+
let res = const_assign_byte_arr::<WITHDRAW_V2_IX_DATA_LEN, 9, 4>(
137+
res,
137138
validator_index.to_le_bytes(),
138139
);
139140
Self(res)

core/src/internal_utils.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ macro_rules! impl_get_le {
4747
macro_rules! impl_set_le {
4848
($set:ident, $field:ident, $t:ty) => {
4949
#[inline]
50-
pub const fn $set(&mut self, val: $t) {
50+
pub fn $set(&mut self, val: $t) {
5151
self.$field = val.to_le_bytes();
5252
}
5353
};
@@ -92,7 +92,7 @@ macro_rules! impl_get {
9292
macro_rules! impl_set {
9393
($set:ident, $field:ident, $t:ty) => {
9494
#[inline]
95-
pub const fn $set(&mut self, val: $t) {
95+
pub fn $set(&mut self, val: $t) {
9696
self.$field = val;
9797
}
9898
};
@@ -125,15 +125,16 @@ macro_rules! impl_set_with_get {
125125
}
126126

127127
pub const fn const_assign_byte_arr<const A: usize, const START: usize, const LEN: usize>(
128-
arr: &mut [u8; A],
128+
mut arr: [u8; A],
129129
val: [u8; LEN],
130-
) {
130+
) -> [u8; A] {
131131
const {
132132
assert!(START + LEN <= A);
133133
}
134134
// safety: bounds checked at comptime above
135135
unsafe {
136136
// guarantee nonoverlapping due to `&mut`
137-
core::ptr::copy_nonoverlapping(val.as_ptr(), arr.as_ptr().add(START).cast_mut(), LEN);
137+
core::ptr::copy_nonoverlapping(val.as_ptr(), arr.as_mut_ptr().add(START).cast(), LEN);
138138
}
139+
arr
139140
}

0 commit comments

Comments
 (0)