Skip to content

Commit e734eb9

Browse files
authored
p-token: Add unsafe to transmutable trait (#65)
Add unsafe
1 parent c149143 commit e734eb9

4 files changed

Lines changed: 6 additions & 4 deletions

File tree

interface/src/state/account.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ impl Account {
151151
}
152152
}
153153

154-
impl Transmutable for Account {
154+
unsafe impl Transmutable for Account {
155155
const LEN: usize = core::mem::size_of::<Account>();
156156
}
157157

interface/src/state/mint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ impl Mint {
8484
}
8585
}
8686

87-
impl Transmutable for Mint {
87+
unsafe impl Transmutable for Mint {
8888
/// The length of the `Mint` account data.
8989
const LEN: usize = core::mem::size_of::<Mint>();
9090
}

interface/src/state/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ pub type COption<T> = ([u8; 4], T);
1010

1111
/// Marker trait for types that can be cast from a raw pointer.
1212
///
13+
/// # Safety
14+
///
1315
/// It is up to the type implementing this trait to guarantee that the cast is
1416
/// safe, i.e., the fields of the type are well aligned and there are no padding
1517
/// bytes.
16-
pub trait Transmutable {
18+
pub unsafe trait Transmutable {
1719
/// The length of the type.
1820
///
1921
/// This must be equal to the size of each individual field in the type.

interface/src/state/multisig.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl Multisig {
3838
}
3939
}
4040

41-
impl Transmutable for Multisig {
41+
unsafe impl Transmutable for Multisig {
4242
/// The length of the `Multisig` account data.
4343
const LEN: usize = core::mem::size_of::<Multisig>();
4444
}

0 commit comments

Comments
 (0)