mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2024-11-24 20:48:55 +00:00
10990c89af
BUG=b:260784028 TEST=tools/clippy Change-Id: Ib2b595385ed04b9480b22549334ce798d980d347 Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4064717 Commit-Queue: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
27 lines
588 B
Rust
27 lines
588 B
Rust
// Copyright 2019 The ChromiumOS Authors
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
use bit_field::*;
|
|
|
|
#[bitfield]
|
|
#[bits = 5]
|
|
#[derive(Debug, PartialEq, Eq)]
|
|
pub struct FiveBits(u8);
|
|
|
|
#[bitfield]
|
|
struct Struct {
|
|
prefix: BitField1,
|
|
five_bits: FiveBits,
|
|
suffix: BitField2,
|
|
}
|
|
|
|
#[test]
|
|
fn test_enum() {
|
|
let mut s = Struct::new();
|
|
assert_eq!(s.get(0, 8), 0b_0000_0000);
|
|
|
|
s.set_five_bits(FiveBits(0b10101));
|
|
assert_eq!(s.get(0, 8), 0b_0010_1010);
|
|
assert_eq!(s.get_five_bits(), FiveBits(0b10101));
|
|
}
|