aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJorge Aparicio <jorge@japaric.io>2017-04-27 18:34:21 -0500
committerJorge Aparicio <jorge@japaric.io>2017-04-27 18:34:21 -0500
commitec2df608ca4c35f044c383b7a4c8ba268657aa15 (patch)
treeea4b4f4eef9e0b584e051b6f7db1bb6093984253 /src
parenta3cc01df672b27d118ce3c0d94ac3ab6f371cf4a (diff)
make `as_ceiling` a general method of `P<N>`
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 239c802..3d08402 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<T> {
_marker: PhantomData<T>,
}
+impl<N> P<N> {
+ /// Turns this priority into a ceiling
+ pub fn as_ceiling(&self) -> &C<N> {
+ unsafe {
+ mem::transmute(self)
+ }
+ }
+}
+
impl<T> P<T>
where
T: Unsigned,