Skip to content

Commit d5b4fad

Browse files
committed
improve Ptr trait
1 parent 5156884 commit d5b4fad

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/lib.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,15 +210,18 @@ impl<RB, const A: usize> Sealed for Periph<RB, A> {}
210210
pub trait Ptr: Sealed {
211211
/// RegisterBlock structure
212212
type RB;
213+
/// Pointer to the register block
214+
const PTR: *const Self::RB;
213215
/// Return the pointer to the register block
214-
fn ptr() -> *const Self::RB;
216+
#[inline(always)]
217+
fn ptr() -> *const Self::RB {
218+
Self::PTR
219+
}
215220
}
216221

217222
impl<RB, const A: usize> Ptr for Periph<RB, A> {
218223
type RB = RB;
219-
fn ptr() -> *const Self::RB {
220-
Self::ptr()
221-
}
224+
const PTR: *const Self::RB = Self::PTR;
222225
}
223226

224227
pub trait Steal: Sealed {
@@ -239,6 +242,7 @@ pub trait Steal: Sealed {
239242
}
240243

241244
impl<RB, const A: usize> Steal for Periph<RB, A> {
245+
#[inline(always)]
242246
unsafe fn steal() -> Self {
243247
Self::steal()
244248
}

0 commit comments

Comments
 (0)