Skip to content

Latest commit

 

History

History
59 lines (31 loc) · 1.28 KB

File metadata and controls

59 lines (31 loc) · 1.28 KB

Rust Patterns

Examples of useful Rust patterns.

Detecting Trait Implementations

Source code

Detects whether T implements certain traits.

When to use:

  • You want to know at runtime whether a type implements certain traits.

Self-Referential Types

Source code

A workaround for self-referential types.

When to use:

  • You need to work with a type such as &'a Type<'a>.

Generic Trait Objects

Source code

Creating a trait object from a trait with generic methods.

When to use:

  • You want to create a trait object from a trait that has generic methods.
  • The generic methods require a 'static lifetime, as in foo<T: 'static>().

Heterogeneous functions in a list

Source code

When to use:

  • You want to manage functions with different signatures in a single collection.
  • You need to call those functions from your code.

ECS: System and Query

Source code

When to use:

  • You want to see how to implement an ECS using systems and queries.

WASM Web Workers with Vite

Source code

When to use:

  • You want to use Web Workers and bundle your JavaScript and WASM with Vite.