Skip to content

Commit

Permalink
Replace let-else
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaopengli89 committed May 10, 2023
1 parent 9174264 commit 9f8aba5
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/platform_impl/macos/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,11 @@ declare_class!(
_actual_range: *mut c_void, // *mut NSRange
) -> NSRect {
trace_scope!("firstRectForCharacterRange:actualRange:");
let Some(window) = self.window() else { return NSRect::default(); };
let window = if let Some(window) = self.window() {
window
} else {
return NSRect::default();
};
let content_rect = window.contentRectForFrameRect(window.frame());
let base_x = content_rect.origin.x as f64;
let base_y = (content_rect.origin.y + content_rect.size.height) as f64;
Expand Down Expand Up @@ -472,7 +476,11 @@ declare_class!(

// Get the characters from the event.
let ev_mods = event_mods(event);
let Some(window) = self.window() else { return; };
let window = if let Some(window) = self.window() {
window
} else {
return;
};
let ignore_alt_characters = match window.option_as_alt() {
OptionAsAlt::OnlyLeft if event.lalt_pressed() => true,
OptionAsAlt::OnlyRight if event.ralt_pressed() => true,
Expand Down Expand Up @@ -611,7 +619,11 @@ declare_class!(
#[sel(insertTab:)]
fn insert_tab(&self, _sender: *const Object) {
trace_scope!("insertTab:");
let Some(window) = self.window() else { return; };
let window = if let Some(window) = self.window() {
window
} else {
return;
};
if let Some(first_responder) = window.firstResponder() {
if *first_responder == ***self {
window.selectNextKeyView(Some(self))
Expand All @@ -622,7 +634,11 @@ declare_class!(
#[sel(insertBackTab:)]
fn insert_back_tab(&self, _sender: *const Object) {
trace_scope!("insertBackTab:");
let Some(window) = self.window() else { return; };
let window = if let Some(window) = self.window() {
window
} else {
return;
};
if let Some(first_responder) = window.firstResponder() {
if *first_responder == ***self {
window.selectPreviousKeyView(Some(self))
Expand Down

0 comments on commit 9f8aba5

Please sign in to comment.