Implement element getters for n-tuples by brendanzab · Pull Request #6591 · rust-lang/rust (original) (raw)

This commit implements element getters for tuples with an arity of 2 to 12. The getters return references to the elements, so no copying occurs. The traits are re-exported in core::prelude so you can use them from regular Rust code.

Here is an example of one of the getters in use:

assert_eq!((2, "hi", 75.0).n1(), &"hi");