From 831b02fc6b6f84143323c0ba0228dac93c40023d Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Tue, 29 Dec 2020 15:17:52 -0800 Subject: [PATCH] Resolve clippy map_unwrap_or lint in demo --- book/src/tutorial.md | 6 +++--- demo/src/main.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/book/src/tutorial.md b/book/src/tutorial.md index a375ea0a..c9fa00cb 100644 --- a/book/src/tutorial.md +++ b/book/src/tutorial.md @@ -320,7 +320,7 @@ pub struct MultiBuf { pub fn next_chunk(buf: &mut MultiBuf) -> &[u8] { let next = buf.chunks.get(buf.pos); buf.pos += 1; - next.map(Vec::as_slice).unwrap_or(&[]) + next.map_or(&[], Vec::as_slice) } # # fn main() { @@ -411,7 +411,7 @@ This is now ready to use. :) # pub fn next_chunk(buf: &mut MultiBuf) -> &[u8] { # let next = buf.chunks.get(buf.pos); # buf.pos += 1; -# next.map(Vec::as_slice).unwrap_or(&[]) +# next.map_or(&[], Vec::as_slice) # } fn main() { @@ -537,7 +537,7 @@ mod ffi { # pub fn next_chunk(buf: &mut MultiBuf) -> &[u8] { # let next = buf.chunks.get(buf.pos); # buf.pos += 1; -# next.map(Vec::as_slice).unwrap_or(&[]) +# next.map_or(&[], Vec::as_slice) # } fn main() { diff --git a/demo/src/main.rs b/demo/src/main.rs index dca596ae..458f1f21 100644 --- a/demo/src/main.rs +++ b/demo/src/main.rs @@ -38,7 +38,7 @@ pub struct MultiBuf { pub fn next_chunk(buf: &mut MultiBuf) -> &[u8] { let next = buf.chunks.get(buf.pos); buf.pos += 1; - next.map(Vec::as_slice).unwrap_or(&[]) + next.map_or(&[], Vec::as_slice) } fn main() {