The guidelines below were approved by RFC #199.
Functions often come in multiple variants: immutably borrowed, mutably borrowed, and owned.
The right default depends on the function in question. Variants should be marked through suffixes.
If foo`foo` uses/produces an immutable borrow by default, use:
_mut`_mutsuffix (e.g.` suffix (e.g. foo_mut`foo_mut`) for the mutably borrowed variant._move`_movesuffix (e.g.` suffix (e.g. foo_move`foo_move`) for the owned variant.If foo`foo` uses/produces owned data by default, use:
_ref`_refsuffix (e.g.` suffix (e.g. foo_ref`foo_ref`) for the immutably borrowed variant._mut`_mutsuffix (e.g.` suffix (e.g. foo_mut`foo_mut`) for the mutably borrowed variant.In the case of iterators, the moving variant can also be understood as
an into`intoconversion,` conversion, into_iter`into_iter, and`, and for x in v.into_iter()`for x in v.into_iter()reads arguably better than` reads
arguably better than for x in v.iter_move()`for x in v.iter_move(), so the convention is`, so the convention is
into_iter`into_iter`.
For mutably borrowed variants, if the mut`mutqualifier is part of a type name (e.g.` qualifier is part of a
type name (e.g. as_mut_slice`as_mut_slice`), it should appear as it would appear
in the type.