Crates.io | current |
lib.rs | current |
version | 0.1.2 |
source | src |
created_at | 2015-01-13 21:21:13.299134 |
updated_at | 2016-09-06 10:28:10.145748 |
description | A library for setting current values for stack scope, such as application structure |
homepage | https://github.com/pistondevelopers/current |
repository | https://github.com/pistondevelopers/current.git |
max_upload_size | |
id | 780 |
size | 7,929 |
A library for setting current values for stack scope, such as application structure
Example project: Sea Birds' Breakfast
See Best coding practices with current objects
This also posts safety guidelines for the library.
In game programming, there are many kinds of "current" values:
There are two ways to use this library:
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 (demonstrating the unsafe version):
e.press(|button| {
let gun = unsafe { &mut *current_gun() };
let player = unsafe { &mut *current_player() };
if button == SHOOT {
gun.shoot(player.aim);
}
});