News for hackers. Stuff that matters.
Re:Should small Rust structs be passed by-copy or by-borrow? by danieldk on Monday August 26, 2019 @09:21AM (#20799631)
Functions can also be generic over references vs. move/copy semantics, e.g.:

    fn foo<T>(frob: T) where T: Borrow<Frob> {
      // Do something with frob.borrow()
    }
Due to monomorpization, foo is specialized for moves/clones when called as foo(frob) where frob is a value type or for borrows when called as foo(&frob). Similarly, you can use Clone, ToOwned or even Into for going in the opposite direction.

Whether such functions are good taste in general is debatable ;).

Re:Should small Rust structs be passed by-copy or by-borrow? by Arnavion on Monday August 26, 2019 @03:58PM (#20803138)
You want AsRef, not Borrow, unless you need the additional guarantees that Borrow provides (identical comparisons and hashing).