whitfin / bytelines Goto Github PK
View Code? Open in Web Editor NEWRead input lines as byte slices for high efficiency
License: MIT License
Read input lines as byte slices for high efficiency
License: MIT License
There are many other popular runtimes besides Tokio, we should add modules for these runtimes too. The two in mind are smol
and async_std
but there are probably others.
At the same time all of these runtimes should be off by default, and opt-in via features in the dependencies. Obviously this will all be a major bump, so we can consider any changes in APIs here too.
It would be great if there would be a function with identical usage, but that also includes the byte offset in the iterator item. I need this because i need to remove some characters from a specific line, but cant because the byte offset i have (from .take(n).fold(0, |count, v| count + v.len())
) would not take into consideration the bytes of the actual newlines characters.
There are many MIT variants out there and it would be very helpful if you would put specific one into the LICENSE file and release new version. This is basically requirement for packaging this crate in Fedora.
At the very least we should include a counterpart for Tokio, and perhaps even a Stream
implementation if possible.
use std::io;
extern crate bytelines;
use bytelines::*;
fn main() {
let stdin = io::stdin();
for _ in stdin.lock().byte_lines() {}
}
$ echo | cargo run
thread 'main' panicked at 'attempt to subtract with overflow', …/bytelines-2.2.1/src/lib.rs:129:36
And the line that panics is:
// also "pop" a leading \r
if self.buffer[n - 1] == b'\r' {
Apologies if I'm not understanding some Rust conventions but it seems to me that that the docs are misleading about the types yielded when iterating over lines. E.g.
// do something with the line, which is &[u8]
whereas really (AIUI) it's Result<&[u8], Error>
. The same is true of several of the comments (and thus in the official docs on crates.io).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.