pistoncore-current

Crates.iopistoncore-current
lib.rspistoncore-current
version0.0.3
sourcesrc
created_at2014-12-11 12:17:19.100418
updated_at2015-12-12 23:55:19.918092
descriptionDEPRECATED. Use `current`.
homepagehttps://github.com/pistondevelopers/current
repositoryhttps://github.com/pistondevelopers/current.git
max_upload_size
id512
size7,562
publish (github:pistondevelopers:publish)

documentation

README

current Build Status

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

Example project: Sea Birds' Breakfast

How to use it

See Best coding practices with current objects

This also posts safety guidelines for the library.

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

There are two ways to use this library:

  • An unsafe version that ease refactoring between current objects and mutable references
  • A safe version that can be used in experimental library design

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);
    }
});

How to contribute

Commit count: 132

cargo fmt