Skip to content

Commit 576a406

Browse files
Daniel-Aaron-Bloomalexandruag
authored andcommitted
Fixed-up examples
Signed-off-by: Daniel Bloom <[email protected]>
1 parent 6a0dcc1 commit 576a406

File tree

5 files changed

+515
-374
lines changed

5 files changed

+515
-374
lines changed

src/address.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,10 @@ pub trait Address:
9595
///
9696
/// ```
9797
/// # use vm_memory::{Address, GuestAddress};
98-
/// let base = GuestAddress(0x100);
99-
/// let addr = GuestAddress(0x150);
100-
/// assert_eq!(addr.unchecked_offset_from(base), 0x50);
98+
/// #
99+
/// let base = GuestAddress(0x100);
100+
/// let addr = GuestAddress(0x150);
101+
/// assert_eq!(addr.unchecked_offset_from(base), 0x50);
101102
/// ```
102103
fn unchecked_offset_from(&self, base: Self) -> Self::V {
103104
self.raw_value() - base.raw_value()

src/endian.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,25 @@
1212
//! # Examples
1313
//!
1414
//! ```
15-
//! # use vm_memory::*;
16-
//! let b: Be32 = From::from(3);
17-
//! let l: Le32 = From::from(3);
15+
//! # use vm_memory::{Be32, Le32};
16+
//! #
17+
//! let b: Be32 = From::from(3);
18+
//! let l: Le32 = From::from(3);
1819
//!
19-
//! assert_eq!(b.to_native(), 3);
20-
//! assert_eq!(l.to_native(), 3);
21-
//! assert!(b == 3);
22-
//! assert!(l == 3);
20+
//! assert_eq!(b.to_native(), 3);
21+
//! assert_eq!(l.to_native(), 3);
22+
//! assert!(b == 3);
23+
//! assert!(l == 3);
2324
//!
24-
//! let b_trans: u32 = unsafe { std::mem::transmute(b) };
25-
//! let l_trans: u32 = unsafe { std::mem::transmute(l) };
25+
//! let b_trans: u32 = unsafe { std::mem::transmute(b) };
26+
//! let l_trans: u32 = unsafe { std::mem::transmute(l) };
2627
//!
27-
//! #[cfg(target_endian = "little")]
28-
//! assert_eq!(l_trans, 3);
29-
//! #[cfg(target_endian = "big")]
30-
//! assert_eq!(b_trans, 3);
28+
//! #[cfg(target_endian = "little")]
29+
//! assert_eq!(l_trans, 3);
30+
//! #[cfg(target_endian = "big")]
31+
//! assert_eq!(b_trans, 3);
3132
//!
32-
//! assert_ne!(b_trans, l_trans);
33+
//! assert_ne!(b_trans, l_trans);
3334
//! ```
3435
3536
use std::mem::{align_of, size_of};

0 commit comments

Comments
 (0)