2 个版本
0.1.1 | 2023 年 9 月 9 日 |
---|---|
0.1.0 | 2021 年 8 月 20 日 |
#161 in 值格式化
用于 svg-nd
26KB
391 行
indent-rs
一组类型和相关特质,用于以适当的缩进来显示层次结构。
示例
use indent_display::{Indenter, NullOptions, DefaultIndentedDisplay};
let mut ind = Indenter::new(&std::io::stdout(), " ", &NullOptions {});
"banana\n".indent(&mut ind);
panic("argh");
用法
将此添加到您的 Cargo.toml
[dependencies]
indent-display = "0.1.0"
版本
版本说明可在 RELEASES.md 中找到。
许可证
许可协议为以下之一
任选其一。
贡献
除非您明确声明,否则根据 Apache-2.0 许可协议定义,您提交给作品以包含在内的任何有意贡献,将以上述方式双重许可,不附加任何额外条款或条件。
lib.rs
:
缩进
这是一个设计用于标准库(不仅仅是核心库)应用的相对简单的缩进显示系统。
use indent_display::{Indenter, NullOptions, DefaultIndentedDisplay, IndentedDisplay};
let mut stdout = std::io::stdout();
let mut ind = Indenter::new(&mut stdout, " ", &NullOptions {});
"Not indented\n".indent(&mut ind);
{
let mut sub = ind.sub();
"Indented once with two spaces\n".indent(&mut ind);
}
{
let mut sub = ind.push("...");
"Indented once with three dots\n".indent(&mut ind);
{
let mut sub = sub.push("***");
"Indented with three dots and three stars\nAnd so is this".indent(&mut ind);
}
{
let mut sub = sub.sub();
"Indented with three dots and two spaces stars\nAnd so is this".indent(&mut ind);
}
}
"Not indented\n".indent(&mut ind);
!