Info
This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: Tuple references
Hi! I wanted to double-check whether Iโm missing something obvious here.
Consider the following simplified code:
fn main() {
let a: A = /* ... */;
let b: B = /* ... */;
let c: C = /* ... */;
g(&a, &b, &c);
h(a, b, c);
}
To make some of the code (including the signatures of g
and h
) a bit cleaner, I thought about introducing a type alias: type Data = (A, B, C)
, so that g
would take &Data
and h
would take Data
. But it seems to me that changing g
's input to &(a,b,c)
would lead to unnecessary cloning because a tuple (a,b,c)
has to be constructed?
This feels like something that should be natural in Rust, but I canโt see a slick way to express it. Am I overlooking an obvious approach?
3 posts - 3 participants
๐ท๏ธ Rust_feed