Resolve clippy map_unwrap_or lint in demo

This commit is contained in:
David Tolnay 2020-12-29 15:17:52 -08:00
parent 515cef8044
commit 831b02fc6b
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
2 changed files with 4 additions and 4 deletions

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

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