Re: [RFC PATCH v5 2/3] rust: add minimal IIO subsystem abstractions

From: Muchamad Coirul Anwar

Date: Wed Sep 02 2026 - 01:06:17 EST


On Tue, 1 Sept 2026 at 08:14, Jonathan Cameron <jic23@xxxxxxxxxx> wrote:

> > > > + Ok(IioVal::Fractional(v, v2)) => {
> > > > + // SAFETY: both `val` and `val2` are valid per the Safety contract.
> > > > + unsafe {
> > > > + *val = v;
> > > > + *val2 = v2.get();
> > >
> > > Why get in some places and not others? May well be a gap in my really limited
> > > rust knowledge.
> >
> > This came up in v3 and I answered it then but forgot to add the comment
> > as I said I would. IioVal::Fractional holds a NonZeroI32 denominator to
> > prevent division-by-zero in iio_format_value(). NonZeroI32 is a newtype
> > wrapper over i32, so .get() is needed to extract the inner i32. The
> > other variants hold plain i32 and don't need it. I'll add an inline
> > comment in v6.
>
> Ah. This is my lack of rust knowledge (and forgetfulness). I'd avoid
> putting too many comments in for the benefit of folk like me who are
> still failing to find the time to learn rust :(

Fair enough, I won't add the extra comment in v6 then, I'll leave it as is.

Thanks
Coirul