Skip to content

Commit

Permalink
Merge pull request #874 from psychon/cleanup
Browse files Browse the repository at this point in the history
Small cleanups
  • Loading branch information
mergify[bot] authored Aug 17, 2023
2 parents 2e9dbb5 + 6bc90f2 commit 3045792
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
5 changes: 1 addition & 4 deletions x11rb/src/cookie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,7 @@ macro_rules! multiple_reply_cookie {
type Item = Result<$reply, ReplyError>;

fn next(&mut self) -> Option<Self::Item> {
let cookie = match self.0.take() {
None => return None,
Some(cookie) => cookie,
};
let cookie = self.0.take()?;
let reply = cookie
.connection
.wait_for_reply_or_error(cookie.sequence_number);
Expand Down
9 changes: 4 additions & 5 deletions x11rb/src/properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ property_cookie! {
|reply| WmSizeHints::from_reply(&reply),
}

const NUM_WM_SIZE_HINTS_ELEMENTS: u32 = 18;
const NUM_WM_SIZE_HINTS_ELEMENTS: u16 = 18;

impl<'a, Conn> WmSizeHintsCookie<'a, Conn>
where
Expand All @@ -185,7 +185,7 @@ where
property,
AtomEnum::WM_SIZE_HINTS,
0,
NUM_WM_SIZE_HINTS_ELEMENTS,
NUM_WM_SIZE_HINTS_ELEMENTS.into(),
)?))
}
}
Expand Down Expand Up @@ -332,7 +332,7 @@ impl WmSizeHints {
property.into(),
AtomEnum::WM_SIZE_HINTS,
32,
NUM_WM_SIZE_HINTS_ELEMENTS,
NUM_WM_SIZE_HINTS_ELEMENTS.into(),
&data,
)
}
Expand Down Expand Up @@ -397,8 +397,7 @@ impl TryParse for WmSizeHints {
impl Serialize for WmSizeHints {
type Bytes = Vec<u8>;
fn serialize(&self) -> Self::Bytes {
// 18*4 surely fits into an usize, so this unwrap() cannot trigger
let mut result = Vec::with_capacity((NUM_WM_SIZE_HINTS_ELEMENTS * 4).try_into().unwrap());
let mut result = Vec::with_capacity((NUM_WM_SIZE_HINTS_ELEMENTS * 4).into());
self.serialize_into(&mut result);
result
}
Expand Down

0 comments on commit 3045792

Please sign in to comment.