-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
doc: advanced metadata topics in book (#407)
- Loading branch information
Showing
3 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
## Advanced topics | ||
|
||
### Bulk decoding of metadata | ||
|
||
To populate a `Vec` with decoded metadata and accounting | ||
for some rows not having metadata: | ||
|
||
* Realize that the decode methods of the `MetadataRoundtrip` trait are associated functions. | ||
* We can use a lending iterator over rows to avoid unnecessary copying. | ||
|
||
Therefore: | ||
|
||
```rust, noplayground, ignore | ||
{{#include ../../tests/book_metadata.rs:metadata_bulk_decode_lending_iter}} | ||
``` | ||
|
||
To filter out rows without metadata: | ||
|
||
```rust, noplayground, ignore | ||
{{#include ../../tests/book_metadata.rs:metadata_bulk_decode_lending_iter_with_filter}} | ||
``` | ||
|
||
The first method gives `Vec<Option<M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters