From ec2df608ca4c35f044c383b7a4c8ba268657aa15 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Thu, 27 Apr 2017 18:34:21 -0500 Subject: make `as_ceiling` a general method of `P` --- src/lib.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src') 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 { _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, -- cgit v1.2.3