Summary

  • Method calls are another type of expression, very similar to function and macro calls

  • Sometimes in Rust, such as with method calls, we have to help the compiler know exactly what type we’re using

  • We can be explicit about which integral type we want by putting the type at the end of the number, e.g., 5_i32

  • We can stick underscores anywhere in a number literal we want, e.g., 80_000_000_u64

  • The negative sign operator will be applied after method calls in general, but you can use parentheses to change the order in which it’s applied, e.g., (-5_i32).abs()

  • The first parameter in a method declaration must be self, &self, or &mut self

  • You can have static methods inside an impl block, called by TypeName::method_name

  • You can use the special type Self inside an impl block

  • You can chain method calls together to build more complex expressions

Get hands-on with 1400+ tech skills courses.