Toward a better list iterator for the kernel
Toward a better list iterator for the kernel
Posted Mar 14, 2022 16:43 UTC (Mon) by laarmen (subscriber, #63948)In reply to: Toward a better list iterator for the kernel by alonz
Parent article: Toward a better list iterator for the kernel
In C, your 'char* str' variable will be the same type before and after your null check, but in Rust those are two separate types. A given "content" can undergo multiple type changes in as many lines as the assumptions are checked, it'd be really tedious to have to come up with new names for essentially the same content.
You can find an example of shadowing in the Rust Book in the second chapter! https://doc.rust-lang.org/book/ch02-00-guessing-game-tuto... (the 'guess' name is reused as we go from the raw input string to the actual integer)
