From 95fa72c3e776b9c19d667dc395e88de5433c6bb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?joseLu=C3=ADs?= Date: Thu, 6 May 2021 21:22:22 +0200 Subject: [PATCH] [rust] update mergedown doc comment - fix more warnings --- rust/src/plane/methods.rs | 20 +++++++++++++------- rust/src/resizecb.rs | 12 ++---------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/rust/src/plane/methods.rs b/rust/src/plane/methods.rs index 58f87e222..f035769e3 100644 --- a/rust/src/plane/methods.rs +++ b/rust/src/plane/methods.rs @@ -1020,18 +1020,24 @@ impl NcPlane { "NcPlane.move_below(NcPlane)" ] } - - /// Merges `source` down onto this NcPlane. + /// Merge the NcPlane `source` down onto the current NcPlane (`self`). + /// + /// This is most rigorously defined as "write to `self` the frame that would + /// be rendered were the entire stack made up only of the specified subregion + /// of `source` and, below it, the subregion of `self` having the specified + /// origin. /// - /// Merging is independent of the position of both NcPlanes on the z-axis. + /// Merging is independent of the position of both planes on the z-axis. /// /// It is an error to define a subregion of zero area, or that is not - /// entirely contained within `source`. + /// entirely contained within `source`. It is an error to define a target + /// origin such that the projected subregion is not entirely contained + /// within `self`. /// - /// It is an error to define a target origin such that the projected - /// subregion is not entirely contained within 'dst'. + /// Behavior is undefined if both planes are equivalent. `self` is modified, + /// but `source` remains unchanged. /// - /// Behavior is undefined if both NcPlanes are equivalent. + /// neither `source` nor `self` may have sprixels. /// /// *C style function: [ncplane_mergedown()][crate::ncplane_mergedown].* pub fn mergedown( diff --git a/rust/src/resizecb.rs b/rust/src/resizecb.rs index c5ad31f23..8cffc1f15 100644 --- a/rust/src/resizecb.rs +++ b/rust/src/resizecb.rs @@ -13,11 +13,7 @@ pub type NcResizeCbUnsafe = unsafe extern "C" fn(*mut NcPlane) -> NcIntResult; /// Converts [NcResizeCbUnsafe] to [NcResizeCb]. pub fn ncresizecb_to_rust(resizecb: Option) -> Option { - if let Some(cb) = resizecb { - Some(unsafe { core::mem::transmute(cb) }) - } else { - None - } + resizecb.map(|cb| unsafe { core::mem::transmute(cb) }) } /// Converts [NcResizeCb] to [NcResizeCbUnsafe]. @@ -25,11 +21,7 @@ pub fn ncresizecb_to_rust(resizecb: Option) -> Option) -> Option { - if let Some(cb) = resizecb { - Some(unsafe { core::mem::transmute(cb) }) - } else { - None - } + resizecb.map(|cb| unsafe { core::mem::transmute(cb) }) } /// Enables the [NcResizeCb] methods.