1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-07-14 18:14:29 +02:00

Merge pull request #122 from marshallpierce/patch-1

Create an empty Vec rather than pre-allocating
This commit is contained in:
Martin Geisler
2023-01-06 17:51:56 +01:00
committed by GitHub

View File

@ -31,7 +31,7 @@ fn log<W: Write>(writer: &mut W, msg: &str) -> Result<()> {
}
fn main() -> Result<()> {
let mut buffer = Vec::with_capacity(1024);
let mut buffer = Vec::new();
log(&mut buffer, "Hello")?;
log(&mut buffer, "World")?;
println!("Logged: {:?}", buffer);