1 个不稳定版本
使用旧的Rust 2015
0.1.0 | 2016年5月12日 |
---|
#15 in #lines
9KB
216 行
string-lines
用于存储字符串行的原始持久数据库。
示例
extern crate string_lines;
use string_lines::StringLines;
fn main() {
let mut lines = StringLines::open(
"target/push_pop.example"
).expect("Unable to open file");
for i in 1..101 {
let line = format!("line {}",i);
let _ = lines.push(&line).expect("Unable to push line");
}
loop {
match lines.pop().expect("Unable to pop line") {
Some(line) => {
println!("{}",line);
},
None => {
break;
}
}
}
}
lib.rs
:
用于存储字符串行的原始持久数据库。
string_lines
可在[Crates.io][string_lines]和[GitHub][github]找到。
示例
use string_lines::StringLines;
let mut lines = StringLines::open(
"target/push_pop.example"
).expect("Unable to open file");
for i in 1..101 {
let line = format!("line {}",i);
let _ = lines.push(&line).expect("Unable to push line");
}
loop {
match lines.pop().expect("Unable to pop line") {
Some(line) => {
println!("{}",line);
},
None => {
break;
}
}
}
依赖
~75KB