Skip to content

Repository files navigation

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.

About

Rust or Wasm examples

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages