Use 'an' or 'a' with `&T`

#1

This is a weird question, so I couldn’t decide which category to use.
Is it more appropriate to use 'an &T’ (when you read it as "an ampersand T" as I do frequently) or 'a &T’ (when read as "a reference to a T")? This has been bugging me because I’ve seen it as both on this forum, and am unsure what is more accepted.

#2

As a long-time technical editor (though not yet for Rust) I prefer “a &T”, read as “a ref T”, and similarly “a mut &T”, read as “a mut ref T”.

Addendum: In other words, it’s the functionality, not the sigil, that’s important.

5 Likes
#3

I personally refer to &T as “a borrow of T”, but I don’t know if there’s a sanctioned colloquial name for this.

2 Likes
#4

There’s merit in using the more colloquial “borrow”, though perhaps &T and &mut T should be “an immutable borrow of T” and “a mutable borrow of T”. Every month there are newbie queries in URLO about whether a “reference” is essentially a C++ pointer. My answer was intended to be both succinct (i.e, very few characters/syllables) and also drill in that it’s a reference, not a pointer.

2 Likes
#5

I think it is better to think of it in terms of &T = shared borrow of T and &mut T = exclusive borrow of T, especially when interior mutability is present.

2 Likes
#6

The official term is “reference”, and so the docs use "a &T", read as “a reference to T.”

7 Likes