line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
10
|
|
|
10
|
|
221361
|
use 5.014; |
|
10
|
|
|
|
|
56
|
|
2
|
10
|
|
|
10
|
|
53
|
use strict; |
|
10
|
|
|
|
|
18
|
|
|
10
|
|
|
|
|
299
|
|
3
|
10
|
|
|
10
|
|
51
|
use warnings; |
|
10
|
|
|
|
|
37
|
|
|
10
|
|
|
|
|
313
|
|
4
|
|
|
|
|
|
|
|
5
|
10
|
|
|
10
|
|
513
|
use Result::Trait (); |
|
10
|
|
|
|
|
20
|
|
|
10
|
|
|
|
|
584
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package Result::Ok; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TOBYINK'; |
10
|
|
|
|
|
|
|
our $VERSION = '0.005'; |
11
|
|
|
|
|
|
|
|
12
|
10
|
|
|
10
|
|
514
|
use Role::Tiny::With; |
|
10
|
|
|
|
|
303
|
|
|
10
|
|
|
|
|
4328
|
|
13
|
|
|
|
|
|
|
with 'Result::Trait'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
'overload'->import( 'Result::Trait'->__OVERLOAD_ARGS__( 'ok', '_peek' ) ); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub new { |
18
|
71
|
|
|
71
|
0
|
243047
|
my $class = shift; |
19
|
|
|
|
|
|
|
|
20
|
71
|
|
|
|
|
411
|
bless [ !!0, [ @_ ] ], $class; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub _handled { |
24
|
94
|
100
|
|
94
|
|
626
|
@_ == 1 |
25
|
|
|
|
|
|
|
? $_[0][0] |
26
|
|
|
|
|
|
|
: ( $_[0][0] = $_[1] ); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub _peek { |
30
|
22
|
|
|
22
|
|
85
|
my ( $self ) = @_; |
31
|
|
|
|
|
|
|
wantarray |
32
|
22
|
100
|
|
|
|
116
|
? @{ $self->[1] } |
|
5
|
|
|
|
|
316
|
|
33
|
|
|
|
|
|
|
: $self->[1][-1]; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub _peek_err { |
37
|
0
|
|
|
0
|
|
0
|
die; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub is_err { |
41
|
28
|
50
|
|
28
|
0
|
84
|
@_ == 1 |
42
|
|
|
|
|
|
|
or Carp::croak( 'Usage: $result->is_err()' ); |
43
|
|
|
|
|
|
|
|
44
|
28
|
|
|
|
|
103
|
!!0; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub is_ok { |
48
|
13
|
50
|
|
13
|
0
|
63
|
@_ == 1 |
49
|
|
|
|
|
|
|
or Carp::croak('Usage: $result->is_ok()'); |
50
|
|
|
|
|
|
|
|
51
|
13
|
|
|
|
|
63
|
!!1; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub unwrap { |
55
|
60
|
|
|
60
|
0
|
1130
|
my ( $self ) = @_; |
56
|
60
|
50
|
|
|
|
142
|
@_ == 1 |
57
|
|
|
|
|
|
|
or Carp::croak( 'Usage: $result->unwrap()' ); |
58
|
|
|
|
|
|
|
|
59
|
60
|
|
|
|
|
201
|
$self->[0] = !!1; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
wantarray |
62
|
60
|
100
|
|
|
|
284
|
? @{ $self->[1] } |
|
13
|
|
|
|
|
577
|
|
63
|
|
|
|
|
|
|
: $self->[1][-1]; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub unwrap_err { |
67
|
7
|
|
|
7
|
0
|
2778
|
my ( $self ) = @_; |
68
|
7
|
50
|
|
|
|
25
|
@_ == 1 |
69
|
|
|
|
|
|
|
or Carp::croak( 'Usage: $result->unwrap_err()' ); |
70
|
|
|
|
|
|
|
|
71
|
7
|
|
|
|
|
19
|
$self->[0] = !!1; |
72
|
|
|
|
|
|
|
|
73
|
7
|
|
|
|
|
21
|
Carp::croak( $self->unwrap() ); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
__END__ |