1
- #![ feature( termination_trait_lib) ]
2
- #![ feature( derive_default_enum) ]
1
+ #![ feature(
2
+ derive_default_enum,
3
+ process_exitcode_placeholder,
4
+ termination_trait_lib
5
+ ) ]
3
6
4
7
//! nothing
5
8
//! =======
6
- //!
9
+ //!
7
10
//! [](https://crates.io/crates/nothing)
8
11
//! [](https://docs.rs/nothing)
9
12
//! [](https://travis-ci.org/btwiuse/nothing)
10
- //!
13
+ //!
11
14
//! This is my own version of [Option](https://doc.rust-lang.org/stable/std/option/enum.Option.html). Definition:
12
- //!
15
+ //!
13
16
//! ```
14
17
//! pub enum Probably<T> {
15
18
//! Nothing,
16
19
//! Something(T),
17
20
//! }
18
21
//! ```
19
- //!
22
+ //!
20
23
//! # Why?
21
- //!
24
+ //!
22
25
//! The point is that you can use [Probably] as the return type of your main function:
23
- //!
26
+ //!
24
27
//! ```
25
28
//! use nothing::{Probably, Nothing};
26
- //!
29
+ //!
27
30
//! fn main() -> Probably<()> {
28
31
//! Nothing
29
32
//! }
30
33
//! ```
31
- //!
32
- //! Exit code is `0` if it is [Something], `1` if [Nothing].
33
- //!
34
+ //!
35
+ //! Exit code is `0` if it is [Something], `1` if [Nothing].
36
+ //!
34
37
//! See [./examples/main.rs](https://github.com/btwiuse/nothing/blob/master/examples/main.rs)
35
- //!
38
+ //!
36
39
//! 
37
- //!
40
+ //!
38
41
//! It's probably nothing.
39
42
40
43
/// [Probably] is modelled after [Option]:
@@ -52,8 +55,8 @@ pub use Probably::{Nothing, Something};
52
55
impl < T > std:: process:: Termination for Probably < T > {
53
56
fn report ( self ) -> i32 {
54
57
match self {
55
- Nothing => 1 ,
56
- _ => 0 ,
58
+ Nothing => std :: process :: ExitCode :: FAILURE . report ( ) ,
59
+ _ => std :: process :: ExitCode :: SUCCESS . report ( ) ,
57
60
}
58
61
}
59
62
}
0 commit comments