[librsvg: 2/12] Update the cast crate, and fix the workaround there was for it




commit 19ac036fc01086e934901da976af962b59093b86
Author: Federico Mena Quintero <federico gnome org>
Date:   Wed Dec 8 09:57:33 2021 -0600

    Update the cast crate, and fix the workaround there was for it
    
    Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/641>

 Cargo.lock          | 12 +++++++++---
 Cargo.toml          |  4 ++--
 src/paint_server.rs |  7 +------
 3 files changed, 12 insertions(+), 11 deletions(-)
---
diff --git a/Cargo.lock b/Cargo.lock
index 952034d8..0885a011 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -174,6 +174,12 @@ dependencies = [
  "rustc_version 0.4.0",
 ]
 
+[[package]]
+name = "cast"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5"
+
 [[package]]
 name = "cfg-expr"
 version = "0.8.1"
@@ -251,7 +257,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index";
 checksum = "1604dafd25fba2fe2d5895a9da139f8dc9b319a5fe5354ca137cbbce4e178d10"
 dependencies = [
  "atty",
- "cast",
+ "cast 0.2.7",
  "clap",
  "criterion-plot",
  "csv",
@@ -276,7 +282,7 @@ version = "0.4.4"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 checksum = "d00996de9f2f7559f7f4dc286073197f83e92256a59ed395f9aac01fe717da57"
 dependencies = [
- "cast",
+ "cast 0.2.7",
  "itertools 0.10.3",
 ]
 
@@ -863,7 +869,7 @@ version = "2.52.4"
 dependencies = [
  "assert_cmd",
  "cairo-rs",
- "cast",
+ "cast 0.3.0",
  "chrono",
  "clap",
  "criterion",
diff --git a/Cargo.toml b/Cargo.toml
index 188fdc33..daeabfd1 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -42,7 +42,7 @@ crate-type = [ "staticlib", "rlib" ]
 # Keep these in sync with respect to the cairo-rs version:
 #   src/lib.rs - toplevel example in the docs
 cairo-rs = { version="0.14.0", features=["v1_16", "png", "pdf", "ps", "svg"] }
-cast = "0.2.3"
+cast = "0.3.0"
 chrono = "0.4.0" # rsvg-convert
 clap = "~2.33.0" # rsvg-convert
 cssparser = "0.27.1"
@@ -75,7 +75,7 @@ xml5ever = "0.16.1"
 [dev-dependencies]
 assert_cmd = "2.0.2"
 cairo-rs = { version="0.14.0", features = ["png"] }
-cast = "0.2.3"
+cast = "0.3.0"
 chrono = "0.4.0"
 criterion = "0.3"
 glib = "0.14.0"
diff --git a/src/paint_server.rs b/src/paint_server.rs
index 2626d60d..e4c75f15 100644
--- a/src/paint_server.rs
+++ b/src/paint_server.rs
@@ -271,12 +271,7 @@ pub fn resolve_color(
 
     let alpha = (f64::from(rgba.alpha) * o).round();
     let alpha = util::clamp(alpha, 0.0, 255.0);
-
-    // For the following I'd prefer to use `cast::u8(alpha).unwrap()`
-    // but the cast crate is erroneously returning Overflow for `u8(255.0)`:
-    // https://github.com/japaric/cast.rs/issues/23
-
-    let alpha = alpha as u8;
+    let alpha = cast::u8(alpha).unwrap();
 
     cssparser::RGBA { alpha, ..rgba }
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]