Created
January 29, 2021 21:10
-
-
Save justanotherdot/74dc5084f9a1a3c2f2a46ee1ab0a60b7 to your computer and use it in GitHub Desktop.
Cloning borrows to things that lack a Clone impl simply return the original borrow.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// NB. fix | |
// #[derive(Debug, Clone)] | |
#[derive(Debug)] | |
struct Context; | |
fn dupe_context(context: &Context) -> Context { | |
context.clone() | |
} | |
fn main() { | |
let context = Context; | |
dupe_context(&context); | |
dbg!(context); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment