linebreak

Crates.iolinebreak
lib.rslinebreak
version0.3.1
sourcesrc
created_at2024-03-10 16:37:21.888337
updated_at2024-07-29 14:40:15.882372
descriptionA library for breaking a given text into lines within a specified width.
homepage
repositoryhttps://github.com/sttk/linebreak-rust
max_upload_size
id1168793
size78,188
Takayuki Sato (sttk)

documentation

https://docs.rs/linebreak

README

linebreak-rust crate.io doc.rs CI Status MIT License

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.

Commit count: 0

cargo fmt