MCPcopy Create free account
hub / github.com/ChristianSchott/boris / borrowing

Function borrowing

example/src/borrowing.rs:5–25  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3fn modify_string(s: &mut String) {}
4
5fn borrowing() {
6 println!("Multiple borrows to an immutable string.");
7 {
8 let owned_string = String::from("Hello");
9
10 let borrow = &owned_string;
11 borrow_string(&owned_string);
12 borrow_string(borrow);
13 }
14
15 let mut mutable_string = String::from("World");
16
17 if mutable_string.is_empty() {
18 mutable_string.push_str("Hello there.");
19 } else {
20 println!("The string is not empty.");
21 modify_string(&mut mutable_string);
22 }
23
24 println!("'{}'", mutable_string);
25}

Callers

nothing calls this directly

Calls 3

borrow_stringFunction · 0.85
modify_stringFunction · 0.85
is_emptyMethod · 0.80

Tested by

no test coverage detected