line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
11
|
|
|
11
|
|
230843
|
use 5.014; |
|
11
|
|
|
|
|
49
|
|
2
|
11
|
|
|
11
|
|
68
|
use strict; |
|
11
|
|
|
|
|
27
|
|
|
11
|
|
|
|
|
233
|
|
3
|
11
|
|
|
11
|
|
62
|
use warnings; |
|
11
|
|
|
|
|
21
|
|
|
11
|
|
|
|
|
326
|
|
4
|
|
|
|
|
|
|
|
5
|
11
|
|
|
11
|
|
4007
|
use Result::Trait (); |
|
11
|
|
|
|
|
30
|
|
|
11
|
|
|
|
|
553
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package Result::Err; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TOBYINK'; |
10
|
|
|
|
|
|
|
our $VERSION = '0.006'; |
11
|
|
|
|
|
|
|
|
12
|
11
|
|
|
11
|
|
4467
|
use Role::Tiny::With; |
|
11
|
|
|
|
|
2684
|
|
|
11
|
|
|
|
|
4289
|
|
13
|
|
|
|
|
|
|
with 'Result::Trait'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
'overload'->import( 'Result::Trait'->__OVERLOAD_ARGS__( 'err', '_peek_err' ) ); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub new { |
18
|
57
|
|
|
57
|
0
|
122330
|
my $class = shift; |
19
|
|
|
|
|
|
|
|
20
|
57
|
|
|
|
|
402
|
bless [ !!0, [ @_ ] ], $class; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub _handled { |
24
|
75
|
100
|
|
75
|
|
500
|
@_ == 1 |
25
|
|
|
|
|
|
|
? $_[0][0] |
26
|
|
|
|
|
|
|
: ( $_[0][0] = $_[1] ); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub _peek { |
30
|
0
|
|
|
0
|
|
0
|
die; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub _peek_err { |
34
|
15
|
|
|
15
|
|
37
|
my ( $self ) = @_; |
35
|
|
|
|
|
|
|
wantarray |
36
|
15
|
100
|
|
|
|
55
|
? @{ $self->[1] } |
|
3
|
|
|
|
|
94
|
|
37
|
|
|
|
|
|
|
: $self->[1][-1]; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub is_err { |
41
|
20
|
50
|
|
20
|
0
|
76
|
@_ == 1 |
42
|
|
|
|
|
|
|
or Carp::croak( 'Usage: $result->is_err()' ); |
43
|
|
|
|
|
|
|
|
44
|
20
|
|
|
|
|
117
|
!!1; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub is_ok { |
48
|
10
|
50
|
|
10
|
0
|
49
|
@_ == 1 |
49
|
|
|
|
|
|
|
or Carp::croak('Usage: $result->is_ok()'); |
50
|
|
|
|
|
|
|
|
51
|
10
|
|
|
|
|
38
|
!!0; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub unwrap { |
55
|
4
|
|
|
4
|
0
|
1443
|
my ( $self ) = @_; |
56
|
4
|
50
|
|
|
|
15
|
@_ == 1 |
57
|
|
|
|
|
|
|
or Carp::croak( 'Usage: $result->unwrap()' ); |
58
|
|
|
|
|
|
|
|
59
|
4
|
|
|
|
|
17
|
Carp::croak( $self->unwrap_err() ); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub unwrap_err { |
63
|
54
|
|
|
54
|
0
|
1000
|
my ( $self ) = @_; |
64
|
54
|
50
|
|
|
|
173
|
@_ == 1 |
65
|
|
|
|
|
|
|
or Carp::croak( 'Usage: $result->unwrap_err()' ); |
66
|
|
|
|
|
|
|
|
67
|
54
|
|
|
|
|
404
|
$self->[0] = !!1; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
wantarray |
70
|
54
|
100
|
|
|
|
288
|
? @{ $self->[1] } |
|
14
|
|
|
|
|
466
|
|
71
|
|
|
|
|
|
|
: $self->[1][-1]; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
1; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
__END__ |