ruk·si

🦀 Rust
as, into and to

Updated at 2024-12-24 03:19

Rust community has some lax rules for naming conventions regarding functions that transform the type of the related entity.

codemeaningspoken
as_*&T ⇉ &U"reference as"
into_*T ⇉ U without copy"consume into"
to_*T ⇉ U with copy"copy to"

The above definition of to_* is the least standard. It's the first term that comes to mind when you are implementing casting, so the usage varies a lot.

to_* can also mean:
     &T ⇉ &U               (the same as as_*)
     &T ⇉ U without copy   (the same as into_* but from a reference)