This commit is contained in:
enforcer007 2022-11-13 15:10:11 +05:30
parent 49e82b270d
commit 262dd69640

View File

@ -5,8 +5,6 @@
// It can enclose and provide immutable access to borrowed data, and clone the data lazily when mutation or ownership is required. // It can enclose and provide immutable access to borrowed data, and clone the data lazily when mutation or ownership is required.
// The type is designed to work with general borrowed data via the Borrow trait. // The type is designed to work with general borrowed data via the Borrow trait.
// I AM NOT DONE
use std::borrow::Cow; use std::borrow::Cow;
fn abs_all<'a, 'b>(input: &'a mut Cow<'b, [i32]>) -> &'a mut Cow<'b, [i32]> { fn abs_all<'a, 'b>(input: &'a mut Cow<'b, [i32]>) -> &'a mut Cow<'b, [i32]> {
@ -42,7 +40,7 @@ fn main() {
let mut input = Cow::from(slice); let mut input = Cow::from(slice);
match abs_all(&mut input) { match abs_all(&mut input) {
// TODO // TODO
Cow::Borrowed(_) => println!("I own this slice!"), Cow::Owned(_) => println!("I own this slice!"),
_ => panic!("expected borrowed value"), _ => panic!("expected borrowed value"),
} }
} }