1
0
Fork 0
forked from wry/wry

autocommit 2022-04-13 21:01:32 CEST

This commit is contained in:
Julian Orth 2022-04-13 21:01:32 +02:00
parent 661a28e5b0
commit 916e3644c3
30 changed files with 681 additions and 73 deletions

View file

@ -187,6 +187,12 @@ impl From<std::io::Error> for OsError {
}
}
impl Default for OsError {
fn default() -> Self {
Errno::default().into()
}
}
impl Error for OsError {}
impl Display for OsError {

View file

@ -7,6 +7,7 @@ pub trait WindowsExt<T> {
T: 'a;
fn array_windows_ext<'a, const N: usize>(&'a self) -> Self::Windows<'a, N>;
fn array_chunks_ext<'a, const N: usize>(&'a self) -> &'a [[T; N]];
}
impl<T> WindowsExt<T> for [T] {
@ -18,6 +19,11 @@ impl<T> WindowsExt<T> for [T] {
fn array_windows_ext<'a, const N: usize>(&'a self) -> Self::Windows<'a, N> {
WindowsIter { slice: self }
}
fn array_chunks_ext<'a, const N: usize>(&'a self) -> &'a [[T; N]] {
let len = self.len() / N;
unsafe { std::slice::from_raw_parts(self.as_ptr() as _, len) }
}
}
pub struct WindowsIter<'a, T, const N: usize> {