ruk·si

🦀 Rust
as, into and to

Updated at 2024-03-19 01:52

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

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 typing some 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)