line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
11
|
|
|
11
|
|
231640
|
use 5.014; |
|
11
|
|
|
|
|
45
|
|
2
|
11
|
|
|
11
|
|
64
|
use strict; |
|
11
|
|
|
|
|
23
|
|
|
11
|
|
|
|
|
248
|
|
3
|
11
|
|
|
11
|
|
58
|
use warnings; |
|
11
|
|
|
|
|
26
|
|
|
11
|
|
|
|
|
341
|
|
4
|
|
|
|
|
|
|
|
5
|
11
|
|
|
11
|
|
537
|
use Result::Trait (); |
|
11
|
|
|
|
|
33
|
|
|
11
|
|
|
|
|
635
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package Result::Ok; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TOBYINK'; |
10
|
|
|
|
|
|
|
our $VERSION = '0.006'; |
11
|
|
|
|
|
|
|
|
12
|
11
|
|
|
11
|
|
539
|
use Role::Tiny::With; |
|
11
|
|
|
|
|
291
|
|
|
11
|
|
|
|
|
4629
|
|
13
|
|
|
|
|
|
|
with 'Result::Trait'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
'overload'->import( 'Result::Trait'->__OVERLOAD_ARGS__( 'ok', '_peek' ) ); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub new { |
18
|
74
|
|
|
74
|
0
|
253768
|
my $class = shift; |
19
|
|
|
|
|
|
|
|
20
|
74
|
|
|
|
|
462
|
bless [ !!0, [ @_ ] ], $class; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub _handled { |
24
|
97
|
100
|
|
97
|
|
722
|
@_ == 1 |
25
|
|
|
|
|
|
|
? $_[0][0] |
26
|
|
|
|
|
|
|
: ( $_[0][0] = $_[1] ); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub _peek { |
30
|
24
|
|
|
24
|
|
65
|
my ( $self ) = @_; |
31
|
|
|
|
|
|
|
wantarray |
32
|
24
|
100
|
|
|
|
167
|
? @{ $self->[1] } |
|
5
|
|
|
|
|
272
|
|
33
|
|
|
|
|
|
|
: $self->[1][-1]; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub _peek_err { |
37
|
0
|
|
|
0
|
|
0
|
die; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub is_err { |
41
|
30
|
50
|
|
30
|
0
|
96
|
@_ == 1 |
42
|
|
|
|
|
|
|
or Carp::croak( 'Usage: $result->is_err()' ); |
43
|
|
|
|
|
|
|
|
44
|
30
|
|
|
|
|
160
|
!!0; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub is_ok { |
48
|
13
|
50
|
|
13
|
0
|
68
|
@_ == 1 |
49
|
|
|
|
|
|
|
or Carp::croak('Usage: $result->is_ok()'); |
50
|
|
|
|
|
|
|
|
51
|
13
|
|
|
|
|
61
|
!!1; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub unwrap { |
55
|
63
|
|
|
63
|
0
|
1180
|
my ( $self ) = @_; |
56
|
63
|
50
|
|
|
|
182
|
@_ == 1 |
57
|
|
|
|
|
|
|
or Carp::croak( 'Usage: $result->unwrap()' ); |
58
|
|
|
|
|
|
|
|
59
|
63
|
|
|
|
|
253
|
$self->[0] = !!1; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
wantarray |
62
|
63
|
100
|
|
|
|
343
|
? @{ $self->[1] } |
|
14
|
|
|
|
|
630
|
|
63
|
|
|
|
|
|
|
: $self->[1][-1]; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub unwrap_err { |
67
|
7
|
|
|
7
|
0
|
3367
|
my ( $self ) = @_; |
68
|
7
|
50
|
|
|
|
28
|
@_ == 1 |
69
|
|
|
|
|
|
|
or Carp::croak( 'Usage: $result->unwrap_err()' ); |
70
|
|
|
|
|
|
|
|
71
|
7
|
|
|
|
|
41
|
$self->[0] = !!1; |
72
|
|
|
|
|
|
|
|
73
|
7
|
|
|
|
|
21
|
Carp::croak( $self->unwrap() ); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
__END__ |