Rust heads into the kernel?
Rust heads into the kernel?
Posted May 1, 2021 0:01 UTC (Sat) by tialaramex (subscriber, #21167)In reply to: Rust heads into the kernel? by micka
Parent article: Rust heads into the kernel?
In some languages the add-assign operator has a result type such that if you write a = (b+= 1) then both a, and b become b + 1. But in Rust that type is always the empty tuple, I just checked and as expected Rust allows me to do this, but not to any sort of integer variable a since (b+= 1) is an empty tuple and thus incompatible.
Posted May 1, 2021 11:14 UTC (Sat)
by mathstuf (subscriber, #69389)
[Link] (1 responses)
And yes, it appears as though assignment does not return a reference to the object as it does in C and C++. One could write a small function which worked that way, but then you lose the `=` spelling of assignment. With lifetime tracking, getting it to work in practice is probably not that easy anyways outside of Copy types.
Posted May 2, 2021 5:47 UTC (Sun)
by tialaramex (subscriber, #21167)
[Link]
I'm excited to see kernel Rust once it does have its own alloc implementation.
Rust heads into the kernel?
Rust heads into the kernel?