Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
file: use a nightly API for DST initialization
The `FileInfo`, `FileSystemInfo`, and `FileSystemVolumeLabel` structs are all DSTs because they end with a `Char16` slice containing a name. A wide pointer (or reference) to such a struct contains two parts: the base memory address, and the number of elements in the slice. Previously there was no officially-documented way to create such a wide pointer, so uefi-rs used a trick that is used [elsewhere in the Rust ecosystem][1]: create a slice matching the type and length of the slice at the end of the struct, but passing in the desired base pointer instead. Then the slice type is cast to match the desired struct type. There is now a standard (albeit currently unstable) API for performing this construction added by [RFC 2580][2]. This requires enabling the `ptr_metadata` feature. The runtime result should be the same, but without relying on undocumented Rust internals. [1]: rust-lang/unsafe-code-guidelines#288 (comment) [2]: https://rust-lang.github.io/rfcs/2580-ptr-meta.html
- Loading branch information