Trait sp_std::ops::BitOrAssign 1.8.0[−][src]
The bitwise OR assignment operator |=
.
Examples
use std::ops::BitOrAssign; #[derive(Debug, PartialEq)] struct PersonalPreferences { likes_cats: bool, likes_dogs: bool, } impl BitOrAssign for PersonalPreferences { fn bitor_assign(&mut self, rhs: Self) { self.likes_cats |= rhs.likes_cats; self.likes_dogs |= rhs.likes_dogs; } } let mut prefs = PersonalPreferences { likes_cats: true, likes_dogs: false }; prefs |= PersonalPreferences { likes_cats: false, likes_dogs: true }; assert_eq!(prefs, PersonalPreferences { likes_cats: true, likes_dogs: true });
Required methods
pub fn bitor_assign(&mut self, rhs: Rhs)
[src]
Performs the |=
operation.
Examples
let mut x = true; x |= false; assert_eq!(x, true); let mut x = false; x |= false; assert_eq!(x, false); let mut x: u8 = 5; x |= 1; assert_eq!(x, 5); let mut x: u8 = 5; x |= 2; assert_eq!(x, 7);