Skip to content

Use match + pattern guard instead of if in visitor #1

@WaffleLapkin

Description

@WaffleLapkin

I propose to change visitor.rs#L40-L45 to

match entry {
    (tag, value) if tag == self.tag => Ok(value),
    _ => Err(A::Error::custom(format!(r#"key "{tag}""#, tag = self.tag))),
}

as rust 1.39 hits stable (rustc 1.38 fails to compile this code, see bind_by_move_pattern_guards). In my opinion, this provides more readable code.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions