Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Implement Debug trait for sync variants of FrozenMap and FrozenVec #65

Merged
merged 3 commits into from
Oct 10, 2023

Conversation

huitseeker
Copy link
Contributor

- partially contributes to Manishearth#32,
- Implements `Debug` trait for those structures where checking for reentrancy is straightforward.
Copy link
Owner

@Manishearth Manishearth left a comment

Choose a reason for hiding this comment

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

I wouldn't have the Debug impl print out map etc; it's private, it should Debug to the hashmap's debug impl directly (and then do the <locked> thing when necessary)

@huitseeker
Copy link
Contributor Author

@Manishearth Refactored, please let me know what you think.

- Replaces the `debug_struct` method with straight `debug_map` for `FrozenMap` and `debug_list` for `FrozenVec`
- Simplifies error handling by moving to `f.debug_tuple()` method instead of the previous `field()` calls based on `DebugStruct`
src/sync.rs Outdated
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.map.try_read() {
Ok(guard) => {
f.debug_map().entries(guard.iter()).finish()
Copy link
Owner

Choose a reason for hiding this comment

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

nit: just use guard.fmt(f)

Copy link
Owner

@Manishearth Manishearth left a comment

Choose a reason for hiding this comment

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

Thanks!

@Manishearth Manishearth merged commit ef8f44e into Manishearth:master Oct 10, 2023
1 check 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