Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
duniter-core
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
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nodes
rust
duniter-core
Commits
de0a303a
Commit
de0a303a
authored
3 years ago
by
Éloïs
Browse files
Options
Downloads
Patches
Plain Diff
feat(kv_typed): impl FromBytes for all SmallVec (use const generics)
parent
06eca4f3
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
tools/kv_typed/src/from_bytes.rs
+11
-15
11 additions, 15 deletions
tools/kv_typed/src/from_bytes.rs
with
11 additions
and
15 deletions
tools/kv_typed/src/from_bytes.rs
+
11
−
15
View file @
de0a303a
...
...
@@ -55,23 +55,19 @@ impl FromBytes for String {
}
}
macro_rules!
impl_from_bytes_for_smallvec
{
(
$
(
$N:literal
),
*
)
=>
{
$
(
impl
<
T
>
FromBytes
for
SmallVec
<
[
T
;
$N
]
>
impl
<
T
,
const
N
:
usize
>
FromBytes
for
SmallVec
<
[
T
;
N
]
>
where
T
:
Copy
+
zerocopy
::
FromBytes
,
[
T
;
N
]:
smallvec
::
Array
<
Item
=
T
>
,
{
type
Err
=
LayoutVerifiedErr
;
fn
from_bytes
(
bytes
:
&
[
u8
])
->
Result
<
Self
,
Self
::
Err
>
{
let
layout_verified
=
zerocopy
::
LayoutVerified
::
<
_
,
[
T
]
>
::
new_slice
(
bytes
)
.ok_or_else
(||
LayoutVerifiedErr
(
stringify!
(
T
))
.into
()
)
?
;
.ok_or
(
LayoutVerifiedErr
(
stringify!
(
T
)))
?
;
Ok
(
SmallVec
::
from_slice
(
layout_verified
.into_slice
()))
}
}
)
*
};
}
impl_from_bytes_for_smallvec!
(
1
,
2
,
4
,
8
,
16
,
32
,
64
);
impl
<
T
>
FromBytes
for
Vec
<
T
>
where
...
...
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