~soywod/pimalaya

email-lib: [PATCH email-lib] v1 APPLIED

Perma Alesheikh: 2
 implement Default using the derive macro
 impl default for structs with simple new methods

 4 files changed, 15 insertions(+), 8 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~soywod/pimalaya/patches/49337/mbox | git am -3
Learn more about email & git

[PATCH email-lib 1/2] implement Default using the derive macro Export this patch

This way is more concise.

Signed-off-by: Perma Alesheikh <me@prma.dev>
---
 pgp/src/wkd.rs | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/pgp/src/wkd.rs b/pgp/src/wkd.rs
index c3e712e..0a820f0 100644
--- a/pgp/src/wkd.rs
+++ b/pgp/src/wkd.rs
@@ -92,12 +92,13 @@ pub fn from(email_address: impl AsRef<str>) -> Result<Self> {
///
/// There are two variants of the URL scheme. `Advanced` should be
/// preferred.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Default)]
enum Variant {
    /// Advanced variant.
    ///
    /// This method uses a separate subdomain and is more flexible.
    /// This method should be preferred.
    #[default]
    Advanced,

    /// Direct variant.
@@ -106,12 +107,6 @@ enum Variant {
    Direct,
}

impl Default for Variant {
    fn default() -> Self {
        Variant::Advanced
    }
}

/// Stores the parts needed to create a Web Key Directory URL.
///
/// NOTE: This is a different `Url` than [`url::Url`] (`url` crate) that is
-- 
2.43.0

[PATCH email-lib 2/2] impl default for structs with simple new methods Export this patch

This will allow default trait in case any users wanted to derive Default
on a wrapper or higher level types.

Signed-off-by: Perma Alesheikh <me@prma.dev>
---
 email/src/account/discover/dns.rs      | 6 ++++++
 email/src/account/discover/http.rs     | 6 ++++++
 oauth/src/v2_0/refresh_access_token.rs | 2 +-
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/email/src/account/discover/dns.rs b/email/src/account/discover/dns.rs
index 5f84fbb..a5764fd 100644
--- a/email/src/account/discover/dns.rs
+++ b/email/src/account/discover/dns.rs
@@ -222,3 +222,9 @@ pub async fn get_submission_srv(&self, domain: &str) -> Result<SRV> {
        self.get_srv(domain, "submission").await
    }
}

impl Default for DnsClient {
    fn default() -> Self {
        Self::new()
    }
}
diff --git a/email/src/account/discover/http.rs b/email/src/account/discover/http.rs
index 1d49e17..3edaa56 100644
--- a/email/src/account/discover/http.rs
+++ b/email/src/account/discover/http.rs
@@ -57,3 +57,9 @@ pub async fn get_config(&self, uri: Uri) -> Result<AutoConfig> {
        Ok(config)
    }
}

impl Default for HttpClient {
    fn default() -> Self {
        Self::new()
    }
}
diff --git a/oauth/src/v2_0/refresh_access_token.rs b/oauth/src/v2_0/refresh_access_token.rs
index c0766ed..6ffc86e 100644
--- a/oauth/src/v2_0/refresh_access_token.rs
+++ b/oauth/src/v2_0/refresh_access_token.rs
@@ -24,7 +24,7 @@ pub enum Error {
/// for now but scopes will be added in the future. This flow exchange
/// a refresh token for a new pair of access token and maybe a refresh
/// token.
#[derive(Debug)]
#[derive(Debug, Default)]
pub struct RefreshAccessToken;

impl RefreshAccessToken {
-- 
2.43.0