Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | 03-May-2022 | - | ||||
src/ | H | 03-May-2022 | - | 71 | 42 | |
.cargo-checksum.json | H A D | 03-May-2022 | 89 | 1 | 1 | |
.gitignore | H A D | 10-Sep-2017 | 43 | 7 | 5 | |
.travis.yml | H A D | 10-Sep-2017 | 102 | 11 | 9 | |
Cargo.toml | H A D | 14-Sep-2017 | 500 | 16 | 13 | |
LICENSE | H A D | 10-Sep-2017 | 1 KiB | 22 | 17 | |
README.md | H A D | 14-Sep-2017 | 1 KiB | 44 | 30 |
README.md
1# Rust StringReader 2 3[![Build Status](https://travis-ci.org/Leopard2A5/rust-stringreader.svg?branch=master)](https://travis-ci.org/Leopard2A5/rust-stringreader) 4 5Provides a wrapper for strings so that they can be consumed via the std::io::Read trait. This is especially useful when writing tests. 6 7## Deprecation 8This create is deprecated. `std::io::Read` is implemented for `&'a [u8]`, which you can get from a String using the `as_bytes` [method](https://doc.rust-lang.org/std/string/struct.String.html#method.as_bytes). 9 10## Example 11 12```rust 13use std::io::{Read, BufRead, BufReader}; 14use stringreader::StringReader; 15 16let mut streader = StringReader::new("Line 1\nLine 2"); 17let mut bufreader = BufReader::new(streader); 18let mut buffer = String::new(); 19 20bufreader.read_line(&mut buffer).unwrap(); 21println!("{}", buffer); 22``` 23 24Prints "Line 1\n". 25 26## Usage 27 28Cargo.toml: 29``` 30[dependencies] 31stringreader = "*" 32``` 33 34lib.rs/main.rs: 35```rust 36extern crate stringreader; 37 38use stringreader::StringReader; 39 40// ... 41let mut reader = StringReader::new("this is a test"); 42// ... 43``` 44