runtime-rs: Use bitwise or assign for bitflags

Use `|=` instead of `+=` while calculating and iterating through a
vector of flags, which makes more sense and prevents situations like
duplicated flags in vector, which would cause problems.

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
This commit is contained in:
Ruoqing He 2025-04-16 14:04:55 +00:00
parent bf93b5daf1
commit d7f4b6cbef
3 changed files with 3 additions and 3 deletions

View File

@ -170,7 +170,7 @@ fn generate_route(name: &str, route_msg: &RouteMessage) -> Result<Option<Route>>
let mut flags: u32 = 0;
for flag in &route_msg.header.flags {
flags += u32::from(*flag);
flags |= u32::from(*flag);
}
let mut route = Route {

View File

@ -60,7 +60,7 @@ impl TryFrom<AddressMessage> for Address {
//thus here just implemeted a simple transformer.
let mut d: u32 = 0;
for flag in &f {
d += u32::from(*flag);
d |= u32::from(*flag);
}
addr.flags = d;
}

View File

@ -16,7 +16,7 @@ impl From<&VecLinkFlag> for u32 {
fn from(v: &VecLinkFlag) -> u32 {
let mut d: u32 = 0;
for flag in &v.0 {
d += u32::from(*flag);
d |= u32::from(*flag);
}
d
}