I'm pretty sure const {} introduces a new item scope, though. If you want to get a value out, you return it, the same as a non-const {}.
FWIW, I'd expect anonymous modules to be written
mod {
// ...
}
or
mod _ {
// ...
}
rather than a bare block.
Personally, I'm not convinced that transparent blocks are really all that useful. If you have one #[cfg(os)], you'll necessarily have at least one more. Also, the likelihood that these require some sort of platform-specific imports to implement their functionality also seems relatively high, at which point you'd like to have them be in a separate namespace to keep those from leaking to the OS-agnostic module.
While I could see the benefit for simple example and/or explanatory code, it seems like most actual use cases would be better served by separate impl files for the different OSes.
And one pattern I've seen to make this easier is using the less-known #[path] attribute for mods to do so for a single mod item:
#[cfg_attr(os(windows), path = "impl_windows")]
#[cfg_attr(os(unix), path = "impl_unix")]
mod impl;
It's up to taste at how many items / how much complexity is enough to warrant pulling out to an auxiliary file like this.