Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Dunitrust
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
nodes
rust
Dunitrust
Commits
c8679325
Commit
c8679325
authored
6 years ago
by
Éloïs
Browse files
Options
Downloads
Patches
Plain Diff
[ref] json-pest-parser: remove block occurrences
parent
eb529db2
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/tools/json-pest-parser/src/lib.rs
+14
-14
14 additions, 14 deletions
lib/tools/json-pest-parser/src/lib.rs
with
14 additions
and
14 deletions
lib/tools/json-pest-parser/src/lib.rs
+
14
−
14
View file @
c8679325
...
...
@@ -231,10 +231,10 @@ fn parse_value<S: std::hash::BuildHasher + Default>(pair: Pair<Rule>) -> JSONVal
}
pub
fn
get_optional_usize
<
S
:
std
::
hash
::
BuildHasher
>
(
json_
block
:
&
HashMap
<&
str
,
JSONValue
<
S
>
,
S
>
,
json_
object
:
&
HashMap
<&
str
,
JSONValue
<
S
>
,
S
>
,
field
:
&
str
,
)
->
Result
<
Option
<
usize
>
,
Error
>
{
Ok
(
match
json_
block
.get
(
field
)
{
Ok
(
match
json_
object
.get
(
field
)
{
Some
(
value
)
=>
{
if
!
value
.is_null
()
{
Some
(
...
...
@@ -257,10 +257,10 @@ pub fn get_optional_usize<S: std::hash::BuildHasher>(
}
pub
fn
get_optional_str_not_empty
<
'a
,
S
:
std
::
hash
::
BuildHasher
>
(
json_
block
:
&
'a
HashMap
<&
str
,
JSONValue
<
S
>
,
S
>
,
json_
object
:
&
'a
HashMap
<&
str
,
JSONValue
<
S
>
,
S
>
,
field
:
&
str
,
)
->
Result
<
Option
<&
'a
str
>
,
Error
>
{
let
result
=
get_optional_str
(
json_
block
,
field
);
let
result
=
get_optional_str
(
json_
object
,
field
);
if
let
Ok
(
Some
(
value
))
=
result
{
if
!
value
.is_empty
()
{
Ok
(
Some
(
value
))
...
...
@@ -273,10 +273,10 @@ pub fn get_optional_str_not_empty<'a, S: std::hash::BuildHasher>(
}
pub
fn
get_optional_str
<
'a
,
S
:
std
::
hash
::
BuildHasher
>
(
json_
block
:
&
'a
HashMap
<&
str
,
JSONValue
<
S
>
,
S
>
,
json_
object
:
&
'a
HashMap
<&
str
,
JSONValue
<
S
>
,
S
>
,
field
:
&
str
,
)
->
Result
<
Option
<&
'a
str
>
,
Error
>
{
Ok
(
match
json_
block
.get
(
field
)
{
Ok
(
match
json_
object
.get
(
field
)
{
Some
(
value
)
=>
{
if
!
value
.is_null
()
{
Some
(
value
.to_str
()
.ok_or_else
(||
ParseJsonError
{
...
...
@@ -291,10 +291,10 @@ pub fn get_optional_str<'a, S: std::hash::BuildHasher>(
}
pub
fn
get_number
<
S
:
std
::
hash
::
BuildHasher
>
(
json_
block
:
&
HashMap
<&
str
,
JSONValue
<
S
>
,
S
>
,
json_
object
:
&
HashMap
<&
str
,
JSONValue
<
S
>
,
S
>
,
field
:
&
str
,
)
->
Result
<
f64
,
Error
>
{
Ok
(
json_
block
Ok
(
json_
object
.get
(
field
)
.ok_or_else
(||
ParseJsonError
{
cause
:
format!
(
"Fail to parse json : field '{}' must exist !"
,
field
),
...
...
@@ -306,10 +306,10 @@ pub fn get_number<S: std::hash::BuildHasher>(
}
pub
fn
get_str
<
'a
,
S
:
std
::
hash
::
BuildHasher
>
(
json_
block
:
&
'a
HashMap
<&
str
,
JSONValue
<
S
>
,
S
>
,
json_
object
:
&
'a
HashMap
<&
str
,
JSONValue
<
S
>
,
S
>
,
field
:
&
str
,
)
->
Result
<&
'a
str
,
Error
>
{
Ok
(
json_
block
Ok
(
json_
object
.get
(
field
)
.ok_or_else
(||
ParseJsonError
{
cause
:
format!
(
"Fail to parse json : field '{}' must exist !"
,
field
),
...
...
@@ -321,10 +321,10 @@ pub fn get_str<'a, S: std::hash::BuildHasher>(
}
pub
fn
get_str_array
<
'a
,
S
:
std
::
hash
::
BuildHasher
>
(
json_
block
:
&
'a
HashMap
<&
str
,
JSONValue
<
S
>
,
S
>
,
json_
object
:
&
'a
HashMap
<&
str
,
JSONValue
<
S
>
,
S
>
,
field
:
&
str
,
)
->
Result
<
Vec
<&
'a
str
>
,
ParseJsonError
>
{
json_
block
json_
object
.get
(
field
)
.ok_or_else
(||
ParseJsonError
{
cause
:
format!
(
"Fail to parse json : field '{}' must exist !"
,
field
),
...
...
@@ -346,10 +346,10 @@ pub fn get_str_array<'a, S: std::hash::BuildHasher>(
}
pub
fn
get_object_array
<
'a
,
S
:
std
::
hash
::
BuildHasher
>
(
json_
block
:
&
'a
JsonObject
<
'a
,
S
>
,
json_
object
:
&
'a
JsonObject
<
'a
,
S
>
,
field
:
&
str
,
)
->
Result
<
Vec
<&
'a
JsonObject
<
'a
,
S
>>
,
ParseJsonError
>
{
json_
block
json_
object
.get
(
field
)
.ok_or_else
(||
ParseJsonError
{
cause
:
format!
(
"Fail to parse json : field '{}' must exist !"
,
field
),
...
...
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