1 The functional record update syntax was used on something other than a struct.
3 Erroneous code example:
6 enum PublicationFrequency {
8 SemiMonthly { days: (u8, u8), annual_special: bool },
11 fn one_up_competitor(competitor_frequency: PublicationFrequency)
12 -> PublicationFrequency {
13 match competitor_frequency {
14 PublicationFrequency::Weekly => PublicationFrequency::SemiMonthly {
15 days: (1, 15), annual_special: false
17 c @ PublicationFrequency::SemiMonthly{ .. } =>
18 PublicationFrequency::SemiMonthly {
19 annual_special: true, ..c // error: functional record update
20 // syntax requires a struct
26 The functional record update syntax is only allowed for structs (struct-like
27 enum variants don't qualify, for example). To fix the previous code, rewrite the
28 expression without functional record update syntax:
31 enum PublicationFrequency {
33 SemiMonthly { days: (u8, u8), annual_special: bool },
36 fn one_up_competitor(competitor_frequency: PublicationFrequency)
37 -> PublicationFrequency {
38 match competitor_frequency {
39 PublicationFrequency::Weekly => PublicationFrequency::SemiMonthly {
40 days: (1, 15), annual_special: false
42 PublicationFrequency::SemiMonthly{ days, .. } =>
43 PublicationFrequency::SemiMonthly {
44 days, annual_special: true // ok!