Skip to content

Make CTimerPwmPeriodChannel::new (and others) compile-time validated for const arguments #541

@bscoggins-msft

Description

@bscoggins-msft

Currently, CTimerPwmPeriodChannel::new returns a Result and can fail at runtime, requiring .expect("...") calls even when the arguments are compile-time constants that are known to be valid.

Requested improvement:
Either:

  1. Make the constructor const fn with compile-time validation - Use const { assert!() } blocks to validate arguments at compile time, making invalid arguments a compiler error rather than runtime panic
  2. Provide a separate const fn new_const() variant that only accepts const arguments and validates them at compile time

Metadata

Metadata

Assignees

No one assigned

    Labels

    core halMCU core HAL functionality

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions