https://github.com/althonos/textwrap-macros
Simple procedural macros to use textwrap utilities at compile time.
https://github.com/althonos/textwrap-macros
Last synced: 4 months ago
JSON representation
Simple procedural macros to use textwrap utilities at compile time.
- Host: GitHub
- URL: https://github.com/althonos/textwrap-macros
- Owner: althonos
- License: mit
- Created: 2020-01-03T22:23:45.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-03-20T05:02:29.000Z (almost 3 years ago)
- Last Synced: 2025-08-23T05:42:05.706Z (5 months ago)
- Language: Rust
- Size: 41 KB
- Stars: 12
- Watchers: 3
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: COPYING
Awesome Lists containing this project
README
# `textwrap-macros` [](https://github.com/althonos/textwrap-macros/stargazers)
*Simple procedural macros to use [`textwrap`] utilities at compile time.*
[`textwrap`]: https://github.com/mgeisler/textwrap
[](https://github.com/althonos/textwrap-macros/actions)
[](https://codecov.io/gh/althonos/textwrap-macros)
[](https://choosealicense.com/licenses/mit/)
[](https://github.com/althonos/textwrap-macros)
[](https://crates.io/crates/textwrap-macros)
[](https://docs.rs/textwrap-macros)
[](https://github.com/althonos/textwrap-macros.rs/blob/master/CHANGELOG.md)
## Usage
Add the `textwrap-macros` crate to the `Cargo.toml` manifest:
```toml
[dependencies]
textwrap-macros = "0.2"
```
Then either use the macros using the old-style `#[macro_use]` or import them as
any other crate member:
```rust
use textwrap_macros::dedent;
const poem: &str = dedent!(r#"
When we two parted
In silence and tears,
Half broken-hearted
To sever for years,
Pale grew thy cheek and cold,
Colder thy kiss;
Truly that hour foretold
Sorrow to this.
"#);
```
Macros usage with small examples can be found on
[`docs.rs`](https://docs.rs/textwrap-macros). The following functions have been
ported into macros:
- [x] [`dedent`](https://docs.rs/textwrap-macros/latest/textwrap_macros/macro.dedent.html)
- [x] [`fill`](https://docs.rs/textwrap-macros/latest/textwrap_macros/macro.fill.html)
- [x] [`indent`](https://docs.rs/textwrap-macros/latest/textwrap_macros/macro.indent.html)
- [x] [`wrap`](https://docs.rs/textwrap-macros/latest/textwrap_macros/macro.wrap.html)
- [ ] [`unfill`](https://docs.rs/textwrap/latest/textwrap/fn.unfill.html)
- [ ] [`refill`](https://docs.rs/textwrap/latest/textwrap/fn.refill.html)
- [ ] [`wrap_columns`](https://docs.rs/textwrap/latest/textwrap/fn.wrap_columns.html)
Check out the [documentation of the original library](https://docs.rs/textwrap/)
for more information about the behaviour of each of the wrapped functions.
## Changelog
This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html)
and provides a [changelog](https://github.com/althonos/textwrap-macros/blob/master/CHANGELOG.md)
in the [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) format.