Skip to content

Return i64 and f64 instead of &i64 and &f64 in Value #2235

@bakageddy

Description

@bakageddy

While going through the codebase, I noticed that Value::as_integer and Value::as_real return Option<&i64> and Option<&f64> respectively, rather than Option and Option.

Since i64 and f64 are both Copy and only 8 bytes (the same size as a reference on a 64-bit target), returning a reference offers no performance benefit and forces every caller to dereference. Is there a specific reason for this, or would a change to return by value be welcome?

For comparison, serde_json::Value::as_i64/as_f64 returns these by value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions