[niepce] Remove deprecated try_opt
- From: Hubert Figuière <hub src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [niepce] Remove deprecated try_opt
- Date: Sat, 3 Jul 2021 16:26:59 +0000 (UTC)
commit 005eb4fd709f3a59c765486dbfc6672e3f3ac609
Author: Hubert Figuière <hub figuiere net>
Date: Sat Jul 3 01:03:56 2021 -0400
Remove deprecated try_opt
Cargo.lock | 20 ++++++-------------
crates/npc-engine/Cargo.toml | 1 -
crates/npc-engine/src/db/libmetadata.rs | 4 ++--
crates/npc-engine/src/db/library.rs | 4 ++--
crates/npc-engine/src/lib.rs | 4 +---
crates/npc-fwk/Cargo.toml | 1 -
crates/npc-fwk/src/lib.rs | 2 --
crates/npc-fwk/src/utils/exempi.rs | 34 ++++++++++++++++-----------------
8 files changed, 28 insertions(+), 42 deletions(-)
---
diff --git a/Cargo.lock b/Cargo.lock
index eedfc0b..7f38ec7 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -692,7 +692,6 @@ dependencies = [
"maplit",
"npc-fwk",
"rusqlite",
- "try_opt",
]
[[package]]
@@ -719,7 +718,6 @@ dependencies = [
"multimap",
"once_cell",
"rexiv2",
- "try_opt",
]
[[package]]
@@ -1106,18 +1104,18 @@ dependencies = [
[[package]]
name = "thiserror"
-version = "1.0.25"
+version = "1.0.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fa6f76457f59514c7eeb4e59d891395fab0b2fd1d40723ae737d64153392e9c6"
+checksum = "93119e4feac1cbe6c798c34d3a53ea0026b0b1de6a120deef895137c0529bfe2"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
-version = "1.0.25"
+version = "1.0.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8a36768c0fbf1bb15eca10defa29526bda730a2376c2ab4393ccfa16fb1a318d"
+checksum = "060d69a0afe7796bf42e9e2ff91f5ee691fb15c53d38b4b62a9a53eb23164745"
dependencies = [
"proc-macro2",
"quote",
@@ -1143,12 +1141,6 @@ dependencies = [
"serde",
]
-[[package]]
-name = "try_opt"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d30b71e7ba40551f9873f3ba9f4ee36f16015adf0962aba57caf403088370db1"
-
[[package]]
name = "ucd-trie"
version = "0.1.3"
@@ -1157,9 +1149,9 @@ checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c"
[[package]]
name = "unicode-segmentation"
-version = "1.7.1"
+version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796"
+checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b"
[[package]]
name = "unicode-width"
diff --git a/crates/npc-engine/Cargo.toml b/crates/npc-engine/Cargo.toml
index 4a14690..625bc06 100644
--- a/crates/npc-engine/Cargo.toml
+++ b/crates/npc-engine/Cargo.toml
@@ -18,7 +18,6 @@ lazy_static = "^1.2.0"
libc = "0.2.39"
maplit = "1.0.2"
rusqlite = { version = "0.25.3", features = ["functions"] }
-try_opt = "0.1.1"
npc-fwk = { path = "../npc-fwk" }
diff --git a/crates/npc-engine/src/db/libmetadata.rs b/crates/npc-engine/src/db/libmetadata.rs
index 6870197..f7d305d 100644
--- a/crates/npc-engine/src/db/libmetadata.rs
+++ b/crates/npc-engine/src/db/libmetadata.rs
@@ -77,7 +77,7 @@ impl LibMetadata {
}
fn get_metadata(&self, meta: Np) -> Option<PropertyValue> {
- let index_to_xmp = try_opt!(property_index_to_xmp(meta));
+ let index_to_xmp = property_index_to_xmp(meta)?;
let mut prop_flags = exempi::PropFlags::default();
let mut xmp_result =
@@ -96,7 +96,7 @@ impl LibMetadata {
}
}
Some(PropertyValue::String(String::from(
- try_opt!(xmp_result.ok()).to_str(),
+ xmp_result.ok()?.to_str(),
)))
}
diff --git a/crates/npc-engine/src/db/library.rs b/crates/npc-engine/src/db/library.rs
index 6620254..cd3f69d 100644
--- a/crates/npc-engine/src/db/library.rs
+++ b/crates/npc-engine/src/db/library.rs
@@ -431,8 +431,8 @@ impl Library {
}
pub fn leaf_name_for_pathname(pathname: &str) -> Option<String> {
- let name = try_opt!(Path::new(pathname).file_name());
- Some(String::from(try_opt!(name.to_str())))
+ let name = Path::new(pathname).file_name()?;
+ Some(String::from(name.to_str()?))
}
fn get_content(&self, id: LibraryId, sql_where: &str) -> Result<Vec<LibFile>> {
diff --git a/crates/npc-engine/src/lib.rs b/crates/npc-engine/src/lib.rs
index 86d0598..86c6901 100644
--- a/crates/npc-engine/src/lib.rs
+++ b/crates/npc-engine/src/lib.rs
@@ -17,11 +17,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-extern crate glib;
-#[macro_use]
-extern crate try_opt;
extern crate gdk_pixbuf;
extern crate gdk_pixbuf_sys;
+extern crate glib;
#[macro_use]
extern crate npc_fwk;
diff --git a/crates/npc-fwk/Cargo.toml b/crates/npc-fwk/Cargo.toml
index c5de5d7..a62404f 100644
--- a/crates/npc-fwk/Cargo.toml
+++ b/crates/npc-fwk/Cargo.toml
@@ -28,7 +28,6 @@ libopenraw-rs = { path = "../../../libopenraw-rs/libopenraw-rs" }
multimap = "0.4.0"
once_cell = "1.8.0"
rexiv2 = "^0.9.1"
-try_opt = "0.1.1"
[build-dependencies]
diff --git a/crates/npc-fwk/src/lib.rs b/crates/npc-fwk/src/lib.rs
index 74fa6e9..f6674c8 100644
--- a/crates/npc-fwk/src/lib.rs
+++ b/crates/npc-fwk/src/lib.rs
@@ -33,8 +33,6 @@ extern crate lazy_static;
extern crate libc;
extern crate multimap;
extern crate once_cell;
-#[macro_use]
-extern crate try_opt;
#[macro_use]
pub mod base;
diff --git a/crates/npc-fwk/src/utils/exempi.rs b/crates/npc-fwk/src/utils/exempi.rs
index f8887c5..07c4be3 100644
--- a/crates/npc-fwk/src/utils/exempi.rs
+++ b/crates/npc-fwk/src/utils/exempi.rs
@@ -326,7 +326,7 @@ impl XmpMeta {
pub fn label(&self) -> Option<String> {
let mut flags: exempi::PropFlags = exempi::PropFlags::default();
- let xmpstring = try_opt!(self.xmp.get_property(NS_XAP, "Label", &mut flags).ok());
+ let xmpstring = self.xmp.get_property(NS_XAP, "Label", &mut flags).ok()?;
Some(String::from(xmpstring.to_str()))
}
@@ -344,21 +344,21 @@ impl XmpMeta {
pub fn creation_date(&self) -> Option<DateTime<Utc>> {
let mut flags: exempi::PropFlags = exempi::PropFlags::default();
- let xmpstring = try_opt!(self
+ let xmpstring = self
.xmp
.get_property(NS_EXIF, "DateTimeOriginal", &mut flags)
- .ok());
- let date = try_opt!(DateTime::parse_from_rfc3339(xmpstring.to_str()).ok());
+ .ok()?;
+ let date = DateTime::parse_from_rfc3339(xmpstring.to_str()).ok()?;
Some(date.with_timezone(&Utc))
}
pub fn creation_date_str(&self) -> Option<String> {
let mut flags: exempi::PropFlags = exempi::PropFlags::empty();
- let xmpstring = try_opt!(self
+ let xmpstring = self
.xmp
.get_property(NS_EXIF, "DateTimeOriginal", &mut flags)
- .ok());
+ .ok()?;
Some(String::from(xmpstring.to_str()))
}
@@ -413,7 +413,7 @@ pub fn gps_coord_from_xmp(xmps: &str) -> Option<f64> {
let degs: &str;
// step 1 - degrees
- let sep = try_opt!(current.find(','));
+ let sep = current.find(',')?;
let (d, remainder) = current.split_at(sep);
current = remainder;
degs = d;
@@ -443,17 +443,17 @@ pub fn gps_coord_from_xmp(xmps: &str) -> Option<f64> {
let (minutes, seconds) = current.split_at(sep);
let (_, seconds) = seconds.split_at(1);
let (seconds, _) = seconds.split_at(seconds.len() - 1);
- let m = try_opt!(minutes.parse::<f64>().ok());
- let s = try_opt!(seconds.parse::<f64>().ok());
+ let m = minutes.parse::<f64>().ok()?;
+ let s = seconds.parse::<f64>().ok()?;
fminutes = m + (s / 60f64);
} else {
// DD,mm.mm format
let (minutes, _) = current.split_at(current.len() - 1);
- let m = try_opt!(minutes.parse::<f64>().ok());
+ let m = minutes.parse::<f64>().ok()?;
fminutes = m;
}
- let mut deg = try_opt!(degs.parse::<f64>().ok());
+ let mut deg = degs.parse::<f64>().ok()?;
if deg > 180.0 {
return None;
}
@@ -477,12 +477,12 @@ pub fn xmp_date_from_exif(d: &str) -> Option<exempi::DateTime> {
err_out!("ymd split failed {:?}", ymd);
return None;
}
- let year = try_opt!(i32::from_str_radix(ymd[0], 10).ok());
- let month = try_opt!(i32::from_str_radix(ymd[1], 10).ok());
+ let year = i32::from_str_radix(ymd[0], 10).ok()?;
+ let month = i32::from_str_radix(ymd[1], 10).ok()?;
if !(1..=12).contains(&month) {
return None;
}
- let day = try_opt!(i32::from_str_radix(ymd[2], 10).ok());
+ let day = i32::from_str_radix(ymd[2], 10).ok()?;
if !(1..=31).contains(&day) {
return None;
}
@@ -491,15 +491,15 @@ pub fn xmp_date_from_exif(d: &str) -> Option<exempi::DateTime> {
err_out!("hms split failed {:?}", hms);
return None;
}
- let hour = try_opt!(i32::from_str_radix(hms[0], 10).ok());
+ let hour = i32::from_str_radix(hms[0], 10).ok()?;
if !(0..=23).contains(&hour) {
return None;
}
- let min = try_opt!(i32::from_str_radix(hms[1], 10).ok());
+ let min = i32::from_str_radix(hms[1], 10).ok()?;
if !(0..=59).contains(&min) {
return None;
}
- let sec = try_opt!(i32::from_str_radix(hms[2], 10).ok());
+ let sec = i32::from_str_radix(hms[2], 10).ok()?;
if !(0..=59).contains(&sec) {
return None;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]