Skip to content

Commit

Permalink
Make stub implementation Infallible.
Browse files Browse the repository at this point in the history
  • Loading branch information
coolreader18 authored Jun 4, 2022
1 parent 3825a1c commit b05c42a
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/stub.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use std::fs::File;
use std::io;

enum Never {}

pub struct MmapInner {
// Private member to prevent external construction
// (might be nice to change the type to ! once that's stable)
__: (),
never: Never,
}

impl MmapInner {
Expand Down Expand Up @@ -40,38 +40,38 @@ impl MmapInner {
}

pub fn flush(&self, _: usize, _: usize) -> io::Result<()> {
unreachable!("self unconstructable");
match self.never {}
}

pub fn flush_async(&self, _: usize, _: usize) -> io::Result<()> {
unreachable!("self unconstructable");
match self.never {}
}

pub fn make_read_only(&mut self) -> io::Result<()> {
unreachable!("self unconstructable");
match self.never {}
}

pub fn make_exec(&mut self) -> io::Result<()> {
unreachable!("self unconstructable");
match self.never {}
}

pub fn make_mut(&mut self) -> io::Result<()> {
unreachable!("self unconstructable");
match self.never {}
}

#[inline]
pub fn ptr(&self) -> *const u8 {
unreachable!("self unconstructable");
match self.never {}
}

#[inline]
pub fn mut_ptr(&mut self) -> *mut u8 {
unreachable!("self unconstructable");
match self.never {}
}

#[inline]
pub fn len(&self) -> usize {
unreachable!("self unconstructable");
match self.never {}
}
}

Expand Down

0 comments on commit b05c42a

Please sign in to comment.