Mercurial > public > mercurial-scm > hg
comparison rust/hg-core/src/utils/hg_path.rs @ 43250:98d996a138de
rust-cross-platform: remove `unimplemented!` to get compile-time errors
We should get a compile-time error that there is missing functionality for the
targeted platform instead of the program breaking at runtime.
Differential Revision: https://phab.mercurial-scm.org/D7107
author | Rapha?l Gom?s <rgomes@octobus.net> |
---|---|
date | Wed, 16 Oct 2019 17:16:23 +0300 |
parents | 3fe40dd6355d |
children | c27e688fcdc3 |
comparison
equal
deleted
inserted
replaced
43249:63d440bef72a | 43250:98d996a138de |
---|---|
256 #[cfg(unix)] | 256 #[cfg(unix)] |
257 { | 257 { |
258 use std::os::unix::ffi::OsStrExt; | 258 use std::os::unix::ffi::OsStrExt; |
259 os_str = std::ffi::OsStr::from_bytes(&hg_path.as_ref().as_bytes()); | 259 os_str = std::ffi::OsStr::from_bytes(&hg_path.as_ref().as_bytes()); |
260 } | 260 } |
261 #[cfg(windows)] | 261 // TODO Handle other platforms |
262 { | 262 // TODO: convert from WTF8 to Windows MBCS (ANSI encoding). |
263 // TODO: convert from Windows MBCS (ANSI encoding) to WTF8. | |
264 unimplemented!(); | |
265 } | |
266 Ok(os_str.to_os_string()) | 263 Ok(os_str.to_os_string()) |
267 } | 264 } |
268 | 265 |
269 pub fn hg_path_to_path_buf<P: AsRef<HgPath>>( | 266 pub fn hg_path_to_path_buf<P: AsRef<HgPath>>( |
270 hg_path: P, | 267 hg_path: P, |
279 #[cfg(unix)] | 276 #[cfg(unix)] |
280 { | 277 { |
281 use std::os::unix::ffi::OsStrExt; | 278 use std::os::unix::ffi::OsStrExt; |
282 buf = HgPathBuf::from_bytes(&os_string.as_ref().as_bytes()); | 279 buf = HgPathBuf::from_bytes(&os_string.as_ref().as_bytes()); |
283 } | 280 } |
284 #[cfg(windows)] | 281 // TODO Handle other platforms |
285 { | 282 // TODO: convert from WTF8 to Windows MBCS (ANSI encoding). |
286 // TODO: convert from WTF8 to Windows MBCS (ANSI encoding). | 283 |
287 unimplemented!(); | |
288 } | |
289 buf.check_state()?; | 284 buf.check_state()?; |
290 Ok(buf) | 285 Ok(buf) |
291 } | 286 } |
292 | 287 |
293 pub fn path_to_hg_path_buf<P: AsRef<Path>>( | 288 pub fn path_to_hg_path_buf<P: AsRef<Path>>( |
298 #[cfg(unix)] | 293 #[cfg(unix)] |
299 { | 294 { |
300 use std::os::unix::ffi::OsStrExt; | 295 use std::os::unix::ffi::OsStrExt; |
301 buf = HgPathBuf::from_bytes(&os_str.as_bytes()); | 296 buf = HgPathBuf::from_bytes(&os_str.as_bytes()); |
302 } | 297 } |
303 #[cfg(windows)] | 298 // TODO Handle other platforms |
304 { | 299 // TODO: convert from WTF8 to Windows MBCS (ANSI encoding). |
305 // TODO: convert from WTF8 to Windows MBCS (ANSI encoding). | 300 |
306 unimplemented!(); | |
307 } | |
308 buf.check_state()?; | 301 buf.check_state()?; |
309 Ok(buf) | 302 Ok(buf) |
310 } | 303 } |
311 | 304 |
312 #[cfg(test)] | 305 #[cfg(test)] |