4 releases (2 breaking)
0.3.1 | Jul 29, 2024 |
---|---|
0.3.0 | Jul 28, 2024 |
0.2.0 | Mar 14, 2024 |
0.1.0 | Mar 10, 2024 |
#334 in Text processing
99 downloads per month
Used in cliargs
73KB
1.5K
SLoC
linebreak-rust
A library for breaking a given text into lines within a specified width. This library also supports per-line indentation.
Install
In Cargo.toml
, write this crate as a dependency.
[dependencies]
linebreak = "0.3.1"
Usage
The usage example of LineIter
struct in this crate is as follows:
use linebreak::LineIter;
fn main() {
let text = "Welcome to The Rust Programming Language, an introductory \
book about Rust. The Rust programming language helps you write faster, \
more reliable software. High-level ergonomics and low-level control are \
often at odds in programming language design; Rust challenges that \
conflict. Through balancing powerful technical capacity and a great \
developer experience, Rust gives you the option to control low-level \
details (such as memory usage) without all the hassle traditionally \
associated with such control.";
let mut iter = LineIter::new(&text, 80);
iter.set_indent("_______");
println!("....:....1....:....2....:....3....:....4....:....5....:....6\
....:....7....:....8");
while let Some(line) = iter.next() {
println!("{}", line);
}
}
The output of the above code is as follows:
....:....1....:....2....:....3....:....4....:....5....:....6....:....7....:....8
_______Welcome to The Rust Programming Language, an introductory book about
_______Rust. The Rust programming language helps you write faster, more reliable
_______software. High-level ergonomics and low-level control are often at odds
_______in programming language design; Rust challenges that conflict. Through
_______balancing powerful technical capacity and a great developer experience,
_______Rust gives you the option to control low-level details (such as memory
_______usage) without all the hassle traditionally associated with such control.
Supporting Rust versions
This crate supports Rust 1.67.1 or later.
% cargo msrv
Fetching index
Determining the Minimum Supported Rust Version (MSRV) for toolchain x86_64-apple-darwin
Using check command cargo check
Check for toolchain '1.66.1-x86_64-apple-darwin' failed with:
┌──────────────────────────────────────────────────────────────────────────────┐
│ error: package `icu_list v1.4.0` cannot be built because it requires rustc │
│ 1.67 or newer, while the currently active rustc version is 1.66.1 │
│ Either upgrade to rustc 1.67 or newer, or use │
│ cargo update -p icu_list@1.4.0 --precise ver │
│ where `ver` is the latest version of `icu_list` supporting rustc 1.66.1 │
└──────────────────────────────────────────────────────────────────────────────┘
Check for toolchain '1.71.1-x86_64-apple-darwin' succeeded
Check for toolchain '1.68.2-x86_64-apple-darwin' succeeded
Check for toolchain '1.67.1-x86_64-apple-darwin' succeeded
Finished The MSRV is: 1.67.1 █████████████████████████████████████ 00:00:03
License
Copyright (C) 2024 Takayuki Sato
This program is free software under MIT License.
See the file LICENSE in this distribution for more details.
Dependencies
~11–47MB
~705K SLoC