mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
Update bool pattern matching into if-else
This commit is contained in:
parent
65370f17c9
commit
abd577bfd4
5 changed files with 50 additions and 49 deletions
|
@ -664,14 +664,13 @@ impl BluetoothManager {
|
||||||
}
|
}
|
||||||
let _ = d.connect();
|
let _ = d.connect();
|
||||||
for _ in 0..MAXIMUM_TRANSACTION_TIME {
|
for _ in 0..MAXIMUM_TRANSACTION_TIME {
|
||||||
match d.is_connected().unwrap_or(false) {
|
if d.is_connected().unwrap_or(false) {
|
||||||
true => return Ok(BluetoothResponse::GATTServerConnect(true)),
|
return Ok(BluetoothResponse::GATTServerConnect(true));
|
||||||
false => {
|
} else {
|
||||||
if is_mock_adapter(&adapter) {
|
if is_mock_adapter(&adapter) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
thread::sleep(Duration::from_millis(CONNECTION_TIMEOUT_MS));
|
thread::sleep(Duration::from_millis(CONNECTION_TIMEOUT_MS));
|
||||||
},
|
|
||||||
}
|
}
|
||||||
// TODO: Step 5.1.4: Use the exchange MTU procedure.
|
// TODO: Step 5.1.4: Use the exchange MTU procedure.
|
||||||
}
|
}
|
||||||
|
@ -693,9 +692,10 @@ impl BluetoothManager {
|
||||||
}
|
}
|
||||||
let _ = d.disconnect();
|
let _ = d.disconnect();
|
||||||
for _ in 0..MAXIMUM_TRANSACTION_TIME {
|
for _ in 0..MAXIMUM_TRANSACTION_TIME {
|
||||||
match d.is_connected().unwrap_or(true) {
|
if d.is_connected().unwrap_or(true) {
|
||||||
true => thread::sleep(Duration::from_millis(CONNECTION_TIMEOUT_MS)),
|
thread::sleep(Duration::from_millis(CONNECTION_TIMEOUT_MS))
|
||||||
false => return Ok(()),
|
} else {
|
||||||
|
return Ok(());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Err(BluetoothError::Network);
|
return Err(BluetoothError::Network);
|
||||||
|
@ -947,13 +947,13 @@ impl BluetoothManager {
|
||||||
let mut adapter = self.get_adapter()?;
|
let mut adapter = self.get_adapter()?;
|
||||||
match self.get_gatt_characteristic(&mut adapter, &id) {
|
match self.get_gatt_characteristic(&mut adapter, &id) {
|
||||||
Some(c) => {
|
Some(c) => {
|
||||||
let result = match enable {
|
let result = if enable {
|
||||||
// (StartNotification) Step 8.
|
// (StartNotification) Step 8.
|
||||||
// TODO: Handle all the errors returned from the start_notify call.
|
// TODO: Handle all the errors returned from the start_notify call.
|
||||||
true => c.start_notify(),
|
c.start_notify()
|
||||||
|
} else {
|
||||||
// (StopNotification) Step 4.
|
// (StopNotification) Step 4.
|
||||||
false => c.stop_notify(),
|
c.stop_notify()
|
||||||
};
|
};
|
||||||
match result {
|
match result {
|
||||||
// (StartNotification) Step 11.
|
// (StartNotification) Step 11.
|
||||||
|
|
|
@ -614,11 +614,12 @@ where
|
||||||
// If we are in multiprocess mode,
|
// If we are in multiprocess mode,
|
||||||
// a dedicated per-process hang monitor will be initialized later inside the content process.
|
// a dedicated per-process hang monitor will be initialized later inside the content process.
|
||||||
// See run_content_process in servo/lib.rs
|
// See run_content_process in servo/lib.rs
|
||||||
let background_monitor_register = match opts::multiprocess() {
|
let background_monitor_register = if opts::multiprocess() {
|
||||||
true => None,
|
None
|
||||||
false => Some(HangMonitorRegister::init(
|
} else {
|
||||||
|
Some(HangMonitorRegister::init(
|
||||||
background_hang_monitor_sender.clone(),
|
background_hang_monitor_sender.clone(),
|
||||||
)),
|
))
|
||||||
};
|
};
|
||||||
|
|
||||||
let (ipc_layout_sender, ipc_layout_receiver) =
|
let (ipc_layout_sender, ipc_layout_receiver) =
|
||||||
|
|
|
@ -6399,13 +6399,10 @@ class CGDictionary(CGThing):
|
||||||
conversion = (
|
conversion = (
|
||||||
"{\n"
|
"{\n"
|
||||||
" rooted!(in(cx) let mut rval = UndefinedValue());\n"
|
" rooted!(in(cx) let mut rval = UndefinedValue());\n"
|
||||||
" match r#try!(get_dictionary_property(cx, object.handle(), \"%s\", rval.handle_mut())) {\n"
|
" if r#try!(get_dictionary_property(cx, object.handle(), \"%s\", rval.handle_mut())) {\n"
|
||||||
" true => {\n"
|
|
||||||
"%s\n"
|
"%s\n"
|
||||||
" },\n"
|
" } else {\n"
|
||||||
" false => {\n"
|
|
||||||
"%s\n"
|
"%s\n"
|
||||||
" },\n"
|
|
||||||
" }\n"
|
" }\n"
|
||||||
"}") % (member.identifier.name, indent(conversion), indent(default))
|
"}") % (member.identifier.name, indent(conversion), indent(default))
|
||||||
|
|
||||||
|
|
|
@ -188,9 +188,10 @@ impl Event {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn status(&self) -> EventStatus {
|
pub fn status(&self) -> EventStatus {
|
||||||
match self.DefaultPrevented() {
|
if self.DefaultPrevented() {
|
||||||
true => EventStatus::Canceled,
|
EventStatus::Canceled
|
||||||
false => EventStatus::NotCanceled,
|
} else {
|
||||||
|
EventStatus::NotCanceled
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,9 +321,10 @@ pub enum EventBubbles {
|
||||||
|
|
||||||
impl From<bool> for EventBubbles {
|
impl From<bool> for EventBubbles {
|
||||||
fn from(boolean: bool) -> Self {
|
fn from(boolean: bool) -> Self {
|
||||||
match boolean {
|
if boolean {
|
||||||
true => EventBubbles::Bubbles,
|
EventBubbles::Bubbles
|
||||||
false => EventBubbles::DoesNotBubble,
|
} else {
|
||||||
|
EventBubbles::DoesNotBubble
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -344,9 +346,10 @@ pub enum EventCancelable {
|
||||||
|
|
||||||
impl From<bool> for EventCancelable {
|
impl From<bool> for EventCancelable {
|
||||||
fn from(boolean: bool) -> Self {
|
fn from(boolean: bool) -> Self {
|
||||||
match boolean {
|
if boolean {
|
||||||
true => EventCancelable::Cancelable,
|
EventCancelable::Cancelable
|
||||||
false => EventCancelable::NotCancelable,
|
} else {
|
||||||
|
EventCancelable::NotCancelable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -304,26 +304,26 @@ pub fn get_descriptor_permission_state(
|
||||||
// The current solution is a workaround with a message box to warn about this,
|
// The current solution is a workaround with a message box to warn about this,
|
||||||
// if the feature is not allowed in non-secure contexcts,
|
// if the feature is not allowed in non-secure contexcts,
|
||||||
// and let the user decide to grant the permission or not.
|
// and let the user decide to grant the permission or not.
|
||||||
let state = match allowed_in_nonsecure_contexts(&permission_name) {
|
let state = if allowed_in_nonsecure_contexts(&permission_name) {
|
||||||
true => PermissionState::Prompt,
|
PermissionState::Prompt
|
||||||
false => match PREFS
|
} else {
|
||||||
|
if PREFS
|
||||||
.get("dom.permissions.testing.allowed_in_nonsecure_contexts")
|
.get("dom.permissions.testing.allowed_in_nonsecure_contexts")
|
||||||
.as_boolean()
|
.as_boolean()
|
||||||
.unwrap_or(false)
|
.unwrap_or(false)
|
||||||
{
|
{
|
||||||
true => PermissionState::Granted,
|
PermissionState::Granted
|
||||||
false => {
|
} else {
|
||||||
settings
|
settings
|
||||||
.as_window()
|
.as_window()
|
||||||
.permission_state_invocation_results()
|
.permission_state_invocation_results()
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
.remove(&permission_name.to_string());
|
.remove(&permission_name.to_string());
|
||||||
prompt_user(&format!(
|
prompt_user(&format!(
|
||||||
"The {} {}",
|
"The {} {}",
|
||||||
permission_name, NONSECURE_DIALOG_MESSAGE
|
permission_name, NONSECURE_DIALOG_MESSAGE
|
||||||
))
|
))
|
||||||
},
|
}
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Step 3.
|
// Step 3.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue