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
ink
Commits
45ee4ba6
Unverified
Commit
45ee4ba6
authored
Dec 11, 2020
by
Michael Müller
Committed by
GitHub
Dec 11, 2020
Browse files
Trim docs whitespaces for metadata (#613)
parent
2652edbc
Pipeline
#116824
failed with stages
in 30 minutes and 40 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
crates/metadata/src/specs.rs
View file @
45ee4ba6
...
...
@@ -352,7 +352,7 @@ impl<S> ConstructorSpecBuilder<S> {
{
let
mut
this
=
self
;
debug_assert!
(
this
.spec.docs
.is_empty
());
this
.spec.docs
=
docs
.into_iter
()
.collect
::
<
Vec
<
_
>>
();
this
.spec.docs
=
docs
.into_iter
()
.
map
(
str
::
trim
)
.
collect
::
<
Vec
<
_
>>
();
this
}
}
...
...
crates/metadata/src/tests.rs
View file @
45ee4ba6
...
...
@@ -169,3 +169,32 @@ fn spec_contract_json() {
})
)
}
#[test]
fn
trim_docs
()
{
// given
let
name
=
"foo"
;
let
cs
=
ConstructorSpec
::
from_name
(
name
)
.selector
(
123_456_789u32
.to_be_bytes
())
.docs
(
vec!
[
" foobar "
])
.done
();
let
mut
registry
=
Registry
::
new
();
let
compact_spec
=
cs
.into_compact
(
&
mut
registry
);
// when
let
json
=
serde_json
::
to_value
(
&
compact_spec
)
.unwrap
();
let
deserialized
:
ConstructorSpec
<
CompactForm
>
=
serde_json
::
from_value
(
json
.clone
())
.unwrap
();
// then
assert_eq!
(
json
,
json!
({
"name"
:
[
"foo"
],
"selector"
:
"0x075bcd15"
,
"args"
:
[],
"docs"
:
[
"foobar"
]
})
);
assert_eq!
(
deserialized
,
compact_spec
);
}
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