Resolve clippy map_unwrap_or lint in demo

This commit is contained in:
David Tolnay
2020-12-29 15:17:52 -08:00
parent 05f33756b6
commit 1efd7dc57f
2 changed files with 4 additions and 4 deletions
+3 -3
View File
@@ -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() {
+1 -1
View File
@@ -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() {