Skip to content

[fontdrasil] panic in Location<Space>.convert #1690

@simoncozens

Description

@simoncozens

This may come down to a philosophical difference: I don't think library code should panic and bring down the application when you call it with the wrong inputs, so I tend to avoid unwrap() (with unwrap_used = "deny") unless I've checked some invariants.

Location.convert does this:

    pub fn convert<ToSpace>(&self, axes: &Axes) -> Location<ToSpace>
    where
        Space: ConvertSpace<ToSpace>,
    {
        self.0
            .iter()
            .map(|(tag, coord)| (*tag, coord.convert(&axes.get(tag).unwrap().converter)))
            .collect()
    }
}

If the tag in the location is not present in the axes, I believe it should be skipped, or an Err raised, but the program should not explode.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions