Convention | Example | General Meaning |
---|---|---|
to_*() |
str::to_string() |
A conversion from one type to another that may have an allocation or computation cost. Usually a Borrowed type to Owned type. |
as_*() |
String::as_str() |
Convert an Owned type into a Borrowed type. It is usually cheap (maybe even zero-cost) to use this function. |
into_*() |
String::into_bytes() |
Consume a type T and convert it into an Owned type U . |
from_*() |
SocketAddr::from_str() |
Create an Owned type from an Owned or Borrowed type. |
*_mut() |
str::split_at_mut() |
Denotes a mutable reference. |
try_*() |
usize::try_from() |
Method will return a Result or Option type. Usually Result . |
with_*() |
Vec::with_capacity() |
A constructor that has one or more parameters used to configure the type. |
-
-
Save Mufanc/632414188c4d54d3fac4bdaf7ccaa713 to your computer and use it in GitHub Desktop.
Rust Naming Conventions
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment