#singleton #piston #global

current

A library for setting current values for stack scope, such as application structure

10 releases (2 stable)

new 1.0.1 Mar 22, 2025
1.0.0 Mar 21, 2025
0.1.2 Sep 6, 2016
0.1.1 Jun 24, 2015
0.0.5 Jan 21, 2015

#313 in Rust patterns

Download history 32/week @ 2024-12-01 79/week @ 2024-12-08 68/week @ 2024-12-15 9/week @ 2024-12-22 10/week @ 2024-12-29 38/week @ 2025-01-05 67/week @ 2025-01-12 64/week @ 2025-01-19 21/week @ 2025-01-26 91/week @ 2025-02-02 66/week @ 2025-02-09 68/week @ 2025-02-16 52/week @ 2025-02-23 33/week @ 2025-03-02 51/week @ 2025-03-09 107/week @ 2025-03-16

262 downloads per month
Used in 7 crates (5 directly)

MIT license

7KB
104 lines

Current

A library for setting current values for stack scope, such as application structure

Current objects are put on a shadow stack for easy access by type. The type is used as an identifier to get the latest current object in scope.

This is used as a better alternative in Rust than mutable globals.

There are two objects in this library:

  • CurrentGuard is used to create a current object using a mutable reference
  • Current is used to access the reference by type

How to use it

See Best coding practices with current objects

No runtime deps