3

In the chrono crate I noticed this:

#[derive(Clone, PartialEq)]
pub struct ParseWeekdayError {
    _dummy: (),
}

What's the purpose of this _dummy field?

at54321
  • 8,726
  • 26
  • 46
  • 12
    Pretty sure its just to introduce a private field to prevent construction outside of the crate. See [How to restrict the construction of struct?](https://stackoverflow.com/questions/53588819/how-to-restrict-the-construction-of-struct) – kmdreko Jan 02 '22 at 20:40

0 Answers0