expression

Test a generic driver against a mock interface

A PAC describes device-specific registers; a HAL exposes higher-level hardware operations; a driver can depend on a trait instead of a particular chip. This no_std library defines an original small teaching trait, NOT the embedded-hal API. Its host harness verifies the successful path and error propagation without a device. Expected host stdout (not executed): high: true failed: true Common mistake: Calling unwrap inside a generic driver or assuming a mock proves electrical behavior.

Formal Syntax & Structure

rust syntaxrust
fn activate<P: Output>(pin: &mut P) -> Result<(), P::Error>

Working Example

Example Snippetrust
#![no_std]pub trait Output {    type Error;    fn set_high(&mut self) -> Result<(), Self::Error>;}pub fn activate<P: Output>(pin: &mut P) -> Result<(), P::Error> { pin.set_high() }
Rust Reference