Package: rust-cookie-store / 0.8.0-1

replace-try_from-with-TryFrom.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
From 11a597024e016b7060bba1dedf5d5c2389181b10 Mon Sep 17 00:00:00 2001
From: kpcyrd <git@rxv.cc>
Date: Sat, 13 Jul 2019 17:42:00 +0200
Subject: [PATCH] Replace try_from crate with std TryFrom

---
 Cargo.toml           |  1 -
 src/cookie.rs        |  2 +-
 src/cookie_domain.rs | 14 +++++++-------
 3 files changed, 8 insertions(+), 9 deletions(-)

--- a/Cargo.toml
+++ b/Cargo.toml
@@ -43,9 +43,6 @@
 [dependencies.time]
 version = "0.1.42"
 
-[dependencies.try_from]
-version = "0.3.2"
-
 [dependencies.url]
 version = "2"
 [dev-dependencies.env_logger]
--- a/src/cookie.rs
+++ b/src/cookie.rs
@@ -6,10 +6,10 @@
 use cookie::{Cookie as RawCookie, CookieBuilder as RawCookieBuilder, ParseError};
 use serde::{Deserialize, Serialize};
 use std::borrow::Cow;
+use std::convert::TryFrom;
 use std::ops::Deref;
 use std::{error, fmt};
 use time;
-use try_from::TryFrom;
 use url::Url;
 
 #[derive(Debug, Clone, PartialEq, Eq)]
--- a/src/cookie_domain.rs
+++ b/src/cookie_domain.rs
@@ -4,7 +4,7 @@
 use idna;
 use publicsuffix;
 use serde::{Deserialize, Serialize};
-use try_from::TryFrom;
+use std::convert::TryFrom;
 use url::{Host, Url};
 
 use crate::utils::is_host_name;
@@ -125,8 +125,8 @@
 /// Construct a `CookieDomain::Suffix` from a string, stripping a single leading '.' if present.
 /// If the source string is empty, returns the `CookieDomain::Empty` variant.
 impl<'a> TryFrom<&'a str> for CookieDomain {
-    type Err = crate::Error;
-    fn try_from(value: &str) -> Result<CookieDomain, Self::Err> {
+    type Error = crate::Error;
+    fn try_from(value: &str) -> Result<CookieDomain, Self::Error> {
         idna::domain_to_ascii(value.trim())
             .map_err(super::IdnaErrors::from)
             .map_err(Into::into)
@@ -149,8 +149,8 @@
 /// performing this step twice, the `From<&cookie::Cookie>` impl should be used,
 /// instead of passing `cookie.domain` to the `From<&str>` impl.
 impl<'a, 'c> TryFrom<&'a RawCookie<'c>> for CookieDomain {
-    type Err = crate::Error;
-    fn try_from(cookie: &'a RawCookie<'c>) -> Result<CookieDomain, Self::Err> {
+    type Error = crate::Error;
+    fn try_from(cookie: &'a RawCookie<'c>) -> Result<CookieDomain, Self::Error> {
         if let Some(domain) = cookie.domain() {
             idna::domain_to_ascii(domain.trim())
                 .map_err(super::IdnaErrors::from)
@@ -181,7 +181,7 @@
 #[cfg(test)]
 mod tests {
     use cookie::Cookie as RawCookie;
-    use try_from::TryFrom;
+    use std::convert::TryFrom;
     use url::Url;
 
     use super::CookieDomain;
@@ -368,7 +368,7 @@
 #[cfg(test)]
 mod serde_tests {
     use serde_json;
-    use try_from::TryFrom;
+    use std::convert::TryFrom;
 
     use crate::cookie_domain::CookieDomain;
     use crate::utils::test::*;