Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Vaultwarden
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Vaultwarden
Commits
4689ed7b
Unverified
Commit
4689ed7b
authored
6 years ago
by
Daniel García
Browse files
Options
Downloads
Patches
Plain Diff
Changed uppercase deserializer to avoid a clone.
parent
084bc2ae
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/util.rs
+9
-9
9 additions, 9 deletions
src/util.rs
with
9 additions
and
9 deletions
src/util.rs
+
9
−
9
View file @
4689ed7b
...
...
@@ -218,7 +218,7 @@ impl<'de> Visitor<'de> for UpCaseVisitor {
let
mut
result_map
=
JsonMap
::
new
();
while
let
Some
((
key
,
value
))
=
map
.next_entry
()
?
{
result_map
.insert
(
upcase_first
(
key
),
upcase_value
(
&
value
));
result_map
.insert
(
upcase_first
(
key
),
upcase_value
(
value
));
}
Ok
(
Value
::
Object
(
result_map
))
...
...
@@ -231,32 +231,32 @@ impl<'de> Visitor<'de> for UpCaseVisitor {
let
mut
result_seq
=
Vec
::
<
Value
>
::
new
();
while
let
Some
(
value
)
=
seq
.next_element
()
?
{
result_seq
.push
(
upcase_value
(
&
value
));
result_seq
.push
(
upcase_value
(
value
));
}
Ok
(
Value
::
Array
(
result_seq
))
}
}
fn
upcase_value
(
value
:
&
Value
)
->
Value
{
if
let
Some
(
map
)
=
value
.as_object
()
{
fn
upcase_value
(
value
:
Value
)
->
Value
{
if
let
Value
::
Object
(
map
)
=
value
{
let
mut
new_value
=
json!
({});
for
(
key
,
val
)
in
map
{
let
processed_key
=
_process_key
(
key
);
for
(
key
,
val
)
in
map
.into_iter
()
{
let
processed_key
=
_process_key
(
&
key
);
new_value
[
processed_key
]
=
upcase_value
(
val
);
}
new_value
}
else
if
let
Some
(
array
)
=
value
.as_array
()
{
}
else
if
let
Value
::
Array
(
array
)
=
value
{
// Initialize array with null values
let
mut
new_value
=
json!
(
vec!
[
Value
::
Null
;
array
.len
()]);
for
(
index
,
val
)
in
array
.iter
()
.enumerate
()
{
for
(
index
,
val
)
in
array
.
into_
iter
()
.enumerate
()
{
new_value
[
index
]
=
upcase_value
(
val
);
}
new_value
}
else
{
value
.clone
()
value
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment