From 2070236695d434902c181230d830449a4b38b4a5 Mon Sep 17 00:00:00 2001 From: nworbnhoj Date: Sun, 24 Apr 2022 20:09:43 +1000 Subject: [PATCH] minor refinements requested on PR --- services/modals/Cargo.toml | 2 +- services/modals/src/lib.rs | 14 +++++++------- services/modals/src/main.rs | 4 ++-- services/modals/src/tests.rs | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/services/modals/Cargo.toml b/services/modals/Cargo.toml index 303e32720..1e2e94d13 100644 --- a/services/modals/Cargo.toml +++ b/services/modals/Cargo.toml @@ -20,7 +20,7 @@ gam = {path="../gam"} trng = {path="../trng"} tts-frontend = {path="../tts"} locales = {path = "../../locales"} -bit_field = "0.10.1" +bit_field = "0.9.0" [target.'cfg(not(any(windows,unix)))'.dependencies] utralib = { path = "../../utralib"} diff --git a/services/modals/src/lib.rs b/services/modals/src/lib.rs index dc45e042e..3cb49db64 100644 --- a/services/modals/src/lib.rs +++ b/services/modals/src/lib.rs @@ -140,8 +140,8 @@ impl Modals { self.unlock(); Ok(()) } - - pub fn add_list(&mut self, items: Vec<&str>) -> Result<(), xous::Error> { + + pub fn add_list(&self, items: Vec<&str>) -> Result<(), xous::Error> { for (_, text) in items.iter().enumerate() { self.add_list_item(text) .or(Err(xous::Error::InternalError))?; @@ -172,16 +172,16 @@ impl Modals { self.unlock(); Ok(String::from(itemname.as_str())) } - + pub fn get_radio_index(&self) -> Result { let msg = Message::new_blocking_scalar(Opcode::GetModalIndex.to_usize().unwrap(), 0, 0, 0, 0); match send_message(self.conn, msg) { Ok(xous::Result::Scalar1(bitfield)) => { let mut i = 0; - while (i < u32::BIT_LENGTH) & !bitfield.get_bit(i) { + while (i < u32::bit_length()) & !bitfield.get_bit(i) { i = i + 1; } - if i < u32::BIT_LENGTH { + if i < u32::bit_length() { Ok(i) } else { Err(xous::Error::InternalError) @@ -209,14 +209,14 @@ impl Modals { self.unlock(); Ok(ret) } - + pub fn get_check_index(&self) -> Result, xous::Error> { let mut ret = Vec::::new(); let msg = Message::new_blocking_scalar(Opcode::GetModalIndex.to_usize().unwrap(), 0, 0, 0, 0); match send_message(self.conn, msg) { Ok(xous::Result::Scalar1(bitfield)) => { let mut i = 0; - while i < u32::BIT_LENGTH { + while i < u32::bit_length() { if bitfield.get_bit(i) { ret.push(i); } diff --git a/services/modals/src/main.rs b/services/modals/src/main.rs index 1400ca3e8..a1989e71d 100644 --- a/services/modals/src/main.rs +++ b/services/modals/src/main.rs @@ -113,7 +113,7 @@ fn xmain() -> ! { Opcode::ModalKeypress.to_u32().unwrap(), Opcode::ModalDrop.to_u32().unwrap(), ); - + let mut list_hash = HashMap::::new(); let mut list_selected = 0u32; @@ -248,7 +248,7 @@ fn xmain() -> ! { continue; } fixed_items.push(manageditem.item); - } + } Some(Opcode::GetModalIndex) => { xous::return_scalar(msg.sender, list_selected as usize).expect("couldn't return list selected"); } diff --git a/services/modals/src/tests.rs b/services/modals/src/tests.rs index 6a5ab083c..7c436a759 100644 --- a/services/modals/src/tests.rs +++ b/services/modals/src/tests.rs @@ -31,7 +31,7 @@ pub(crate) fn spawn_test() { thread::spawn({ move || { let xns = XousNames::new().unwrap(); - let mut modals = modals::Modals::new(&xns).unwrap(); + let modals = modals::Modals::new(&xns).unwrap(); let tt = ticktimer_server::Ticktimer::new().unwrap(); // 1. test progress bar