mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-06 02:25:23 +00:00
book: update cross platform code samples
Our original code sample was missing some elements in the use statements that clarified how modules were organized with sys. BUG=none TEST=n/a Change-Id: I62d6a294218fa7c9c5853dbefc6550de763e7c8e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3614852 Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Noah Gold <nkgold@google.com> Reviewed-by: Vikram Auradkar <auradkar@google.com>
This commit is contained in:
parent
55a5b54bf2
commit
fdd42b7b0e
1 changed files with 8 additions and 6 deletions
|
@ -396,12 +396,14 @@ File: `sys.rs`
|
|||
cfg_if::cfg_if! {
|
||||
if #[cfg(unix)] {
|
||||
pub mod unix;
|
||||
pub use self::unix::print_hello;
|
||||
use unix as platform;
|
||||
} else if #[cfg(windows)] {
|
||||
pub mod windows;
|
||||
pub use self::windows::print_hello;
|
||||
use windows as platform;
|
||||
}
|
||||
}
|
||||
|
||||
pub use platform::print;
|
||||
```
|
||||
|
||||
File: `unix.rs`
|
||||
|
@ -434,16 +436,16 @@ The user of the library, say mylib, now has to do something like below which mak
|
|||
the functions `print_u8` and `print_u16` are platform specific.
|
||||
|
||||
```rust
|
||||
use mylib::print_hello;
|
||||
use mylib::sys::print;
|
||||
|
||||
fn my_print() {
|
||||
print_hello();
|
||||
print();
|
||||
|
||||
#[cfg(unix)]
|
||||
mylib::unix::print_u8(1);
|
||||
mylib::sys::unix::print_u8(1);
|
||||
|
||||
#[cfg(windows)]
|
||||
mylib::windows::print_u16(1);
|
||||
mylib::sys::windows::print_u16(1);
|
||||
}
|
||||
|
||||
```
|
||||
|
|
Loading…
Reference in a new issue