RustConf 2023 - How Powerful is Const

Unlock the power of const in Rust with this in-depth conference talk, covering its uses in type parameters, assertions, generics, unions, and more.

Key takeaways
  • Const values are immutable.
  • Const can be used as a parameter to a type.
  • Contrasting const and static values.
  • Using const to represent U size 64.
  • Const generics.
  • Const assertions.
  • Using const with slices.
  • Converting enums to integers.
  • Thinking about conditional typing with const.
  • Creating a wrapper struct for bytes.
  • Using const with strings, including UTF-16 and UTF-8.
  • Providing data by taking the string’s pointer.
  • Using const with unions.
  • Impulse crate.
  • Contrepr crate.
  • Transcoding strings from UTF-8 to UTF-16.
  • Creating a loop to handle concatenation.
  • Using const with loops.
  • Const can also be used as a compile-time evaluation.
  • Const can be used to perform lossless conversion.
  • Const can be used in unions.
  • Const can be used to make C happy.
  • Const can be used to work with tuples.
  • Const can be used to create a generic type.
  • Const can be used to make a type implement a given set of traits.
  • Const can be used to conditionally evaluate a type.
  • Const can be used to concatenate null bytes.
  • Using const with size specifically.
  • Using const with unsigned integers.
  • Const can be used with enum variants.
  • Using const with associative constants on types.
  • Using const with traits.
  • Const can be used with compile-time assertions.
  • Const can be used to check if an assertion passes.
  • Const can be used with panic.
  • Const can be used to make a type alias.
  • Const can be used to wrap logic.
  • Using const with proxies.
  • Const can be used with integers.
  • Using const with U size 64.
  • Const can be used to create a generic type.
  • Const can be used to perform conditional typing.
  • Const can be used to make C happy.
  • Const can be used to work with arrays.
  • Const can be used to concatenate slices.
  • Const can be used to create a loop to handle concatenation.
  • Const can be used to make C happy.
  • Const can be used to work with strings.
  • Const can be used with UTF-16 and UTF-8.
  • Providing data by taking the string’s pointer.
  • Using const with unions and enums.
  • Impulse crate.
  • Contrepr crate.
  • Better align to handle array representation.
  • Making C happy.