You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
15 lines
499 B
Rust
15 lines
499 B
Rust
use std::fs::File;
|
|
use std::io::Read;
|
|
fn main() -> std::io::Result<()> {
|
|
// Open two file handles for reading
|
|
let f1 = File::open("file1.txt")?;
|
|
let f2 = File::open("file3.txt")?;
|
|
//Chain the two file handles
|
|
let mut chained_handle = f1.chain(f2);
|
|
// Create a buffer to read into
|
|
let mut buffer = String::new();
|
|
// Read from chained handle into buffer
|
|
chained_handle.read_to_string(&mut buffer)?;
|
|
println!("Read from chained handle: {}", buffer);
|
|
Ok(())
|
|
} |