Skip to content

Add Area (measurement) #60

@vhrcgcom

Description

@vhrcgcom

Description

Implement Area as a ValueObject in the measurement module.

Spec: non-negative f64 with unit (m², cm², ft²)

Implementation checklist

  • Create src/measurement/area.rs
  • Implement ValueObject trait
  • Add #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
  • Export from src/measurement/mod.rs and prelude
  • Unit tests: valid input · empty input · invalid format · normalisation
  • Doc comment with # Example block
  • Update status in ROADMAP.md from ⬜ to ✅

Implementation detail

Input / Output

Area is a composite value object that carries both a numeric value and a unit.

Type
Input AreaInput { value: f64, unit: AreaUnit }
Output String — e.g. "50.0 m²", "538.20 ft²"

Define a unit enum in the same file:

AreaUnit { M2, Cm2, Ft2 }

AreaUnit must derive Debug, Clone, Copy, PartialEq.

Validation

  • value must be >= 0.0 and finite.

Extra methods

  • amount() -> f64
  • unit() -> AreaUnit
  • to_square_meters() -> f64 — convert to m² at call time.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions