diff --git a/build.rs b/build.rs index 0de38e02ea..e320c82815 100644 --- a/build.rs +++ b/build.rs @@ -55,7 +55,6 @@ fn main() { // Priorities for i in 0..(1 << bits) + 1 { - let c = Ident::new(format!("C{}", i)); let p = Ident::new(format!("P{}", i)); let u = Ident::new(format!("U{}", i)); @@ -76,15 +75,6 @@ fn main() { quote! { #[doc = #doc] pub type #p = P<::typenum::#u>; - - impl #p { - /// Turns this priority into a ceiling - pub fn as_ceiling(&self) -> &#c { - unsafe { - ::core::mem::transmute(self) - } - } - } }, ); } diff --git a/src/lib.rs b/src/lib.rs index 239c80234c..3d08402d30 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -436,7 +436,7 @@ extern crate typenum; use core::cell::UnsafeCell; use core::marker::PhantomData; -use core::ptr; +use core::{mem, ptr}; use cortex_m::ctxt::Context; use cortex_m::interrupt::Nr; @@ -719,6 +719,15 @@ pub struct P { _marker: PhantomData, } +impl P { + /// Turns this priority into a ceiling + pub fn as_ceiling(&self) -> &C { + unsafe { + mem::transmute(self) + } + } +} + impl P where T: Unsigned,