docs: simplify doctest
This commit is contained in:
parent
8f36598cac
commit
e8eb019e99
1 changed files with 13 additions and 16 deletions
29
src/read.rs
29
src/read.rs
|
@ -34,24 +34,21 @@ mod ffi {
|
||||||
/// Wrapper for reading the contents of a ZIP file.
|
/// Wrapper for reading the contents of a ZIP file.
|
||||||
///
|
///
|
||||||
/// ```no_run
|
/// ```no_run
|
||||||
/// use std::io::prelude::*;
|
/// # use std::io::prelude::*;
|
||||||
/// fn main() -> zip::result::ZipResult<()> {
|
/// # fn main() -> zip::result::ZipResult<()> {
|
||||||
|
/// # let buf: &[u8] = &[0u8; 128];
|
||||||
|
/// # let mut reader = std::io::Cursor::new(buf);
|
||||||
|
/// # let mut stdout = std::io::stdout();
|
||||||
|
/// # let mut stdout = stdout.lock();
|
||||||
|
/// let mut zip = zip::ZipArchive::new(reader)?;
|
||||||
///
|
///
|
||||||
/// // For demonstration purposes we read from an empty buffer.
|
/// for i in 0..zip.len() {
|
||||||
/// // Normally a File object would be used.
|
/// let mut file = zip.by_index(i)?;
|
||||||
/// let buf: &[u8] = &[0u8; 128];
|
/// println!("Filename: {}", file.name());
|
||||||
/// let mut reader = std::io::Cursor::new(buf);
|
/// std::io::copy(&mut file, &mut stdout);
|
||||||
///
|
|
||||||
/// let mut zip = zip::ZipArchive::new(reader)?;
|
|
||||||
///
|
|
||||||
/// for i in 0..zip.len() {
|
|
||||||
/// let mut file = zip.by_index(i).unwrap();
|
|
||||||
/// println!("Filename: {}", file.name());
|
|
||||||
/// let first_byte = file.bytes().next().unwrap()?;
|
|
||||||
/// println!("{}", first_byte);
|
|
||||||
/// }
|
|
||||||
/// Ok(())
|
|
||||||
/// }
|
/// }
|
||||||
|
/// # Ok(())
|
||||||
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct ZipArchive<R: Read + io::Seek> {
|
pub struct ZipArchive<R: Read + io::Seek> {
|
||||||
|
|
Loading…
Add table
Reference in a new issue