1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2024-12-04 11:39:42 +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
commit e074b8c87f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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);