0

There is a popular c++ application of the chain-of-responsibility design pattern using static "maker" objects linked into a list during the static initialization phase. E.g. https://github.com/alex4747-pub/simple_init_chain.

I would like to use the same pattern in Rust. Is it possible?

Update: found the ctor library in Rust, it seems like it could be used for this purpose https://docs.rs/ctor/latest/ctor/

uuu777
  • 765
  • 4
  • 21
  • Usually, in rust, instead of static initialization before `main`, lazy initialization is done instead (using e.g. [once_cell::sync::Lazy](https://docs.rs/once_cell/latest/once_cell/sync/struct.Lazy.html)), so not sure if there exist any tools to control before main static initializers. – Filipe Rodrigues Feb 22 '23 at 18:01

0 Answers0