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() {