comparison rust/hg-core/src/utils/hg_path.rs @ 49004:9dcfd1d05e6e stable

rust-hgpath: add `repr(transparent)` to `HgPath` It's been stabilized a long time ago, so let's not rely on an implementation detail now. Differential Revision: https://phab.mercurial-scm.org/D12433
author Rapha?l Gom?s <rgomes@octobus.net>
date Tue, 05 Apr 2022 10:55:28 +0200
parents 6d69e83e6b6e
children c7fb9b74e753
comparison
equal deleted inserted replaced
49003:ce919b1a1063 49004:9dcfd1d05e6e
142 /// needed; `HgPath` can be transformed into a platform-specific path (`OsStr` 142 /// needed; `HgPath` can be transformed into a platform-specific path (`OsStr`
143 /// or `Path`) whenever more complex operations are needed: 143 /// or `Path`) whenever more complex operations are needed:
144 /// On Unix, it's just byte-to-byte conversion. On Windows, it has to be 144 /// On Unix, it's just byte-to-byte conversion. On Windows, it has to be
145 /// decoded from MBCS to WTF-8. If WindowsUTF8Plan is implemented, the source 145 /// decoded from MBCS to WTF-8. If WindowsUTF8Plan is implemented, the source
146 /// character encoding will be determined on a per-repository basis. 146 /// character encoding will be determined on a per-repository basis.
147 //
148 // FIXME: (adapted from a comment in the stdlib)
149 // `HgPath::new()` current implementation relies on `Slice` being
150 // layout-compatible with `[u8]`.
151 // When attribute privacy is implemented, `Slice` should be annotated as
152 // `#[repr(transparent)]`.
153 // Anyway, `Slice` representation and layout are considered implementation
154 // detail, are not documented and must not be relied upon.
155 #[derive(Eq, Ord, PartialEq, PartialOrd, Hash)] 147 #[derive(Eq, Ord, PartialEq, PartialOrd, Hash)]
148 #[repr(transparent)]
156 pub struct HgPath { 149 pub struct HgPath {
157 inner: [u8], 150 inner: [u8],
158 } 151 }
159 152
160 impl HgPath { 153 impl HgPath {