Merge branch 'improved-mmio' into 'master'

Allow Mmio to work with const fn

See merge request redox-os/syscall!43
This commit is contained in:
Jeremy Soller
2020-02-10 14:40:29 +00:00
2 changed files with 17 additions and 3 deletions
+1 -1
View File
@@ -5,7 +5,7 @@ pub struct Error {
pub errno: i32,
}
pub type Result<T> = result::Result<T, Error>;
pub type Result<T, E = Error> = result::Result<T, E>;
impl Error {
pub fn new(errno: i32) -> Error {
+16 -2
View File
@@ -11,9 +11,23 @@ pub struct Mmio<T> {
impl<T> Mmio<T> {
/// Create a new Mmio without initializing
#[deprecated = "unsound because it's possible to read even though it's uninitialized"]
pub fn new() -> Self {
Mmio {
value: MaybeUninit::uninit()
unsafe { Self::uninit() }
}
pub unsafe fn zeroed() -> Self {
Self {
value: MaybeUninit::zeroed(),
}
}
pub unsafe fn uninit() -> Self {
Self {
value: MaybeUninit::uninit(),
}
}
pub const fn from(value: T) -> Self {
Self {
value: MaybeUninit::new(value),
}
}
}