Skip to content

thoughtram/read-ext

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#Extensions for Rusts standard Read trait

This adds read_into_string and read_into_vec as specified in this RFC.

##How to use

extern crate readext;

use std::io::{Cursor};
use readext::ReadExt;

#[test]
fn can_read_into_string () {
    let bytes = b"hello";
    let mut input = Cursor::new(bytes as &[u8]);
    let s = input.read_into_string().unwrap();
    assert_eq!(s, "hello");
}


#[test]
fn can_read_into_vec () {
    let bytes = b"hello";
    let mut input = Cursor::new(bytes as &[u8]);
    let s = input.read_into_vec().unwrap();
    assert_eq!(s.len(), 5);
}

About

Extensions for Rusts standard Read trait

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages