roguelike-tutorial icon indicating copy to clipboard operation
roguelike-tutorial copied to clipboard

Simplify struct creations with the `Default` trait

Open tomassedovic opened this issue 6 years ago • 0 comments
trafficstars

For example, the Object::new method could be simplified to something like this:

Object {
    x: x,
    y: y,
    char: char,
    color: color,
    name: name.into(),
    blocks: blocks,
    level: 1,
    .. default::Default(),
}

Removing all the None and false values. That would simplify the tutorial as we wouldn't have to change the structs so often. The Game one seems like another likely candidate.

tomassedovic avatar Oct 01 '19 21:10 tomassedovic