Comments (4)
Nice find. This is fixed in bstr 1.9.1
.
from bstr.
Please provide a full program and an example invocation on the CLI that reproduces the problem. Please include actual output and expected output.
from bstr.
Full program for bstr use case:
use bstr::io::BufReadExt;
use std::io::{self, stdin, BufReader, IsTerminal};
fn main() -> io::Result<()> {
if stdin().is_terminal() {
let mut buf_in = BufReader::new(stdin());
let separator = b'\n';
println!("Start terminal input for bstr for_byte_record_with_terminator\nTry ^D - it will not exit right away on the first ^D");
let _result_bstr = buf_in.for_byte_record_with_terminator(separator, |_line| {
// do something with line
Ok(true)
})?;
println!("Done");
}
Ok(())
}
Run with cargo run
and it will wait for user input in the terminal. Try ^D
(Control-D) and notice that it does not exit, still accepting input in the terminal. Try ^D
twice - it should exit to command prompt
from bstr.
Full program to illustrate that using std::io
functions in the same scenario does exit on the first ^D
:
use std::io::{self, stdin, BufRead, BufReader, IsTerminal};
fn main() -> io::Result<()> {
if stdin().is_terminal() {
let buf_in = BufReader::new(stdin());
let separator = b'\n';
println!("Start terminal input for std io, like split, read_until, etc\nTry ^D");
let _result_std = buf_in.split(separator).for_each(|_line| {
// do something with line
});
println!("Done");
}
Ok(())
}
Run with cargo run
and it will wait for user input in the terminal. Try ^D
(Control-D) once and notice that it does exit into command prompt right away.
from bstr.
Related Issues (20)
- Complementary ByteSlice functions addition - find_not_byte / rfind_not_byte HOT 1
- Use clippy in CI? HOT 2
- Intradoc links are broken when building with no default features HOT 3
- re-enable miri tests
- Accept array of str for split_str HOT 1
- remove `Borrow<BStr> for String` impls (and similar) in a semver compatible release HOT 9
- Add unescape_ascii fn HOT 4
- Display implementation doesn't respect Formatter options
- `bstr::Split` should implement clone. HOT 1
- Incorrect Output rfind() HOT 7
- Should the documentation be updated to take into_encoded_bytes and related functions into account?
- Grapheme segmentation is 1.2x-8x slower than `unicode-segmentation` in benchmarks HOT 3
- `[u8]::utf8_chunks` in std will conflict with the definition in `bstr`
- Can `memchr` be an optional dependency? HOT 5
- Support for `databake`, `writeable`, `zerovec` traits? HOT 3
- Support for the Bytes crate HOT 6
- Unsound usages of unsafe implementation from `u8` to `usize` HOT 3
- Unsound usages of unsafe implementation from `[u8]` to `BStr` HOT 3
- Discrepancy in upper/lower case in `impl fmt::Debug for BStr` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bstr.