Skip to content

Latest commit

 

History

History
53 lines (31 loc) · 1.19 KB

File metadata and controls

53 lines (31 loc) · 1.19 KB

rust-patterns

Rust patterns

Trait impl detect

Source code

Detects whether T implements some traits

When to use

  • Want to know if a type implements some traits at run-time.

Self referential type

Source code

A workaround for self referential types

When to use

  • If you need to deal with something like &'a Type<'a>.

Generic trait object

Source code

Trait object from trait with generic methods

When to use

  • Want to make a trait obejct from a trait having some generic methods.
  • Generic methods require 'static lifetime such as foo<T: 'static>().

Heterogeneous functions in a list

Source code

When to use

  • When you want to manager functions that have different signatures from each other.
  • You need to call them in your code.

ECS: System and Query

Source code

When to use

  • When you want to see how to implement ECS in terms of system and query.

WASM web worker with Webpack

Source code

When to use

  • When you want to use web worker and bundle your JS and wasm with Webpack.