Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@ThierryBerger
Copy link
Contributor

Related to #596

Tests

Run this branch with cargo expand ArchivedTest -p rkyv --example readme to find the added documentation.

An automated test with deny(missing_docs) would be a great addition but let's discuss first.

let field_doc = format!(
"The archived counterpart of [`{}:{}`]",
name,
field_name.map_or("unnamed".to_string(), |s| s.to_string())
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnamed fields should probably be better handled with their indices, but I'll continue after a validation.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be able to get the index by doing for (i, field) in fields.iter().enumerate() and ident.map_or_else(|| &index as &dyn Display, |name| &name as &dyn Display). Coercing to &dyn Display is a little more complicated than converting both to a string, but it does technically avoid an allocation. I also checked that you can make doc links to tuple fields by using their index as the name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Should we have testing on those documentations ?

It's a tiny bit tricky to test because we should probably create a new library dedicated to testing which should deny missing docs 🤔 ; maybe better to leave for another PR?

let field_doc = format!(
"The archived counterpart of [`{}:{}`]",
name,
field_name.map_or("unnamed".to_string(), |s| s.to_string())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be able to get the index by doing for (i, field) in fields.iter().enumerate() and ident.map_or_else(|| &index as &dyn Display, |name| &name as &dyn Display). Coercing to &dyn Display is a little more complicated than converting both to a string, but it does technically avoid an allocation. I also checked that you can make doc links to tuple fields by using their index as the name.

@ThierryBerger ThierryBerger requested a review from djkoloski April 16, 2025 21:24
@djkoloski djkoloski merged commit 1d3adfb into rkyv:main Apr 17, 2025
45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants