-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I'm experimenting with a `Buffer` trait similar to #908, however I've run into a few problems. See the questions in examples/new_read.rs for details.
- Loading branch information
1 parent
f377e85
commit 2b47fd2
Showing
6 changed files
with
178 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use rustix::io::read; | ||
use rustix::stdio::stdin; | ||
|
||
fn main() { | ||
let buf = Vec::new(); | ||
let _x: Vec<u8> = read(stdin(), buf).unwrap(); | ||
|
||
let mut buf = Vec::new(); | ||
let _x: usize = read(stdin(), &mut buf).unwrap(); | ||
|
||
let mut buf = [0, 0, 0]; | ||
let _x: usize = read(stdin(), &mut buf).unwrap(); | ||
|
||
// Why doesn't this work? This is reduced from src/fs/inotify.rs line 177. | ||
struct Wrapper<'a>(&'a mut [u8]); | ||
impl<'a> Wrapper<'a> { | ||
fn read(&mut self) { | ||
let _x: usize = read(stdin(), self.0).unwrap(); | ||
} | ||
} | ||
let mut buf = Vec::new(); | ||
let mut wrapper = Wrapper(&mut buf); | ||
wrapper.read(); | ||
|
||
// Why does this get two error messages? | ||
let mut buf = [0, 0, 0]; | ||
let _x = read(stdin(), buf).unwrap(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters