Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
parity
Mirrored projects
parity-scale-codec
Commits
c860966e
Unverified
Commit
c860966e
authored
Oct 06, 2020
by
Bastian Köcher
Committed by
GitHub
Oct 06, 2020
Browse files
Implement Encode and Decode for empty arrays (#224)
parent
e456502f
Pipeline
#109699
passed with stages
in 16 minutes and 57 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/codec.rs
View file @
c860966e
...
@@ -328,6 +328,8 @@ impl<S: Decode + FullEncode> FullCodec for S {}
...
@@ -328,6 +328,8 @@ impl<S: Decode + FullEncode> FullCodec for S {}
/// Such types should not carry any additional information
/// Such types should not carry any additional information
/// that would require to be encoded, because the encoding
/// that would require to be encoded, because the encoding
/// is assumed to be the same as the wrapped type.
/// is assumed to be the same as the wrapped type.
///
/// The wrapped type that is referred to is the [`Deref::Target`].
pub
trait
WrapperTypeEncode
:
Deref
{}
pub
trait
WrapperTypeEncode
:
Deref
{}
impl
<
T
:
?
Sized
>
WrapperTypeEncode
for
Box
<
T
>
{}
impl
<
T
:
?
Sized
>
WrapperTypeEncode
for
Box
<
T
>
{}
...
@@ -665,7 +667,7 @@ macro_rules! impl_array {
...
@@ -665,7 +667,7 @@ macro_rules! impl_array {
}
}
impl_array!
(
impl_array!
(
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
12
,
13
,
14
,
15
,
16
,
0
,
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
,
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
,
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
,
68
,
69
,
70
,
71
,
52
,
53
,
54
,
55
,
56
,
57
,
58
,
59
,
60
,
61
,
62
,
63
,
64
,
65
,
66
,
67
,
68
,
69
,
70
,
71
,
...
@@ -1567,4 +1569,12 @@ mod tests {
...
@@ -1567,4 +1569,12 @@ mod tests {
let
obj
=
<
String
>
::
decode
(
&
mut
bytes
);
let
obj
=
<
String
>
::
decode
(
&
mut
bytes
);
assert!
(
obj
.is_err
());
assert!
(
obj
.is_err
());
}
}
#[test]
fn
empty_array_encode_and_decode
()
{
let
data
:
[
u32
;
0
]
=
[];
let
encoded
=
data
.encode
();
assert!
(
encoded
.is_empty
());
<
[
u32
;
0
]
>
::
decode
(
&
mut
&
encoded
[
..
])
.unwrap
();
}
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment