Struct Chain

#[non_exhaustive]
pub struct Chain<T, U> { pub first: T, pub second: U, pub done_first: bool }

Adapter to chain together two readers.

This struct is generally created by calling chain on a reader. Please see the documentation of chain for more details.

Fields

first: T
second: U
done_first: bool

Implementations

impl<T, U> Chain<T, U>

fn into_inner(self) -> (T, U)

Consumes the Chain, returning the wrapped readers.

Examples

use std::io;
use std::io::prelude::*;
use std::fs::File;

fn main() -> io::Result<()> {
    let mut foo_file = File::open("foo.txt")?;
    let mut bar_file = File::open("bar.txt")?;

    let chain = foo_file.chain(bar_file);
    let (foo_file, bar_file) = chain.into_inner();
    Ok(())
}
fn get_ref(&self) -> (&T, &U)

Gets references to the underlying readers in this Chain.

Care should be taken to avoid modifying the internal I/O state of the underlying readers as doing so may corrupt the internal state of this Chain.

Examples

use std::io;
use std::io::prelude::*;
use std::fs::File;

fn main() -> io::Result<()> {
    let mut foo_file = File::open("foo.txt")?;
    let mut bar_file = File::open("bar.txt")?;

    let chain = foo_file.chain(bar_file);
    let (foo_file, bar_file) = chain.get_ref();
    Ok(())
}
fn get_mut(&mut self) -> (&mut T, &mut U)

Gets mutable references to the underlying readers in this Chain.

Care should be taken to avoid modifying the internal I/O state of the underlying readers as doing so may corrupt the internal state of this Chain.

Examples

use std::io;
use std::io::prelude::*;
use std::fs::File;

fn main() -> io::Result<()> {
    let mut foo_file = File::open("foo.txt")?;
    let mut bar_file = File::open("bar.txt")?;

    let mut chain = foo_file.chain(bar_file);
    let (foo_file, bar_file) = chain.get_mut();
    Ok(())
}

Trait Implementations

impl<T, U> SizeHint for Chain<T, U>

fn lower_bound(&self) -> usize
fn upper_bound(&self) -> Option<usize>

impl<T: Debug, U: Debug> Debug for Chain<T, U>

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Auto Trait Implementations

impl<T, U> Freeze for Chain<T, U> where T: Freeze, U: Freeze,

impl<T, U> RefUnwindSafe for Chain<T, U> where T: RefUnwindSafe, U: RefUnwindSafe,

impl<T, U> Send for Chain<T, U> where T: Send, U: Send,

impl<T, U> Sync for Chain<T, U> where T: Sync, U: Sync,

impl<T, U> Unpin for Chain<T, U> where T: Unpin, U: Unpin,

impl<T, U> UnsafeUnpin for Chain<T, U> where T: UnsafeUnpin, U: UnsafeUnpin,

impl<T, U> UnwindSafe for Chain<T, U> where T: UnwindSafe, U: UnwindSafe,

Blanket Implementations

impl<T> Any for Chain<T, U> where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for Chain<T, U> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for Chain<T, U> where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> From<T> for Chain<T, U>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> SizeHint for Chain<T, U> where T: ?Sized,

fn lower_bound(&self) -> usize
fn upper_bound(&self) -> Option<usize>

impl<T> SizedTypeProperties for Chain<T, U>

impl<T, U> Into<U> for Chain<T, U> where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for Chain<T, U> where U: Into<T>,

type Error = Infallible;
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto<U> for Chain<T, U> where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>