Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
current
A library for setting current values for stack scope, such as application structure
Example project: Sea Birds' Breakfast
How to use it
Declare an unsafe function, prefixed with current_
to indicate that a current object is used:
unsafe
When you want to use the current object in a function, you do this:
let window_guard = new; // make window current object
start; // function that uses the current object.
drop; // put back old current object
Inside the function where you use the current object, you can call the function and use it as an object:
This works because the Current
implements Deref
and DerefMut
which gets a reference to the current object for the scope it is used.
You can also assign a new value to the current object and get a copy if the object implements Copy
:
// `health` is u32 so we can dereference it to get the value and also assign a new one.
*current_health = *current_health - 1;
This can also be done with more advanced objects, because Rust calls drop
and cleans up the old object before it gets replaced with a new one.
Read more in the issue for Best coding practices with current objects
Motivation
In game programming, there are many kinds of "current" values:
- The current window
- The current device
- The current sound driver
- The current player object
By setting these up as "current" values, you don't have to pass them around to each method. For example, you can write code like this:
e.press;
This makes it easier to decouple data from each other in the application structure.
The major motivation for this library is to have a convention that works across libraries.