Skip to content

Instantly share code, notes, and snippets.

@justanotherdot
Created January 29, 2021 21:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justanotherdot/74dc5084f9a1a3c2f2a46ee1ab0a60b7 to your computer and use it in GitHub Desktop.
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.
// 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