1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#![allow(unknown_lints)]
extern crate alga;
extern crate arrayvec;
extern crate decorum;
#[macro_use]
extern crate failure;
#[macro_use]
extern crate gfx;
extern crate gfx_device_gl;
extern crate gfx_window_glutin;
extern crate glutin;
extern crate image;
#[macro_use]
extern crate lazy_static;
extern crate nalgebra;
extern crate num;
extern crate plexus;
extern crate rand;
extern crate winit;
pub mod clamp;
pub mod cube;
pub mod event;
pub mod framework;
pub mod input;
pub mod math;
pub mod render;
pub mod resource;
pub trait BoolExt: Sized {
fn into_some<T>(self, some: T) -> Option<T>;
}
impl BoolExt for bool {
fn into_some<T>(self, some: T) -> Option<T> {
if self {
Some(some)
}
else {
None
}
}
}
pub trait OptionExt<T> {
fn and_if<F>(self, f: F) -> Self
where
F: Fn(&T) -> bool;
}
impl<T> OptionExt<T> for Option<T> {
fn and_if<F>(mut self, f: F) -> Self
where
F: Fn(&T) -> bool,
{
match self.take() {
Some(value) => if f(&value) {
Some(value)
}
else {
None
},
_ => None,
}
}
}