~soywod/pimalaya

rename new backend sync builder's to try_new v1 APPLIED

Perma Alesheikh: 1
 rename new backend sync builder's to try_new

 1 files changed, 2 insertions(+), 2 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/49786/mbox | git am -3
Learn more about email & git

[PATCH] rename new backend sync builder's to try_new Export this patch

Since new usually indicates returning self, we should use another name
for this function. We can use 'build' for the name of the function,
however the function is recieving a builder, and making another builder,
and using 'build' can cause a bit of a confusion.

We can also use TryFrom, except that the function is neither under the
namespace of the input, nor is it under the namespace of the output.
So I just renamed it to try_new for now.

But I think there still is room for improvement on this one, TBH.

Signed-off-by: Perma Alesheikh <me@prma.dev>
---
 email/src/account/sync/mod.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/email/src/account/sync/mod.rs b/email/src/account/sync/mod.rs
index f60b3af..84f8b70 100644
--- a/email/src/account/sync/mod.rs
+++ b/email/src/account/sync/mod.rs
@@ -27,8 +27,8 @@
pub struct AccountSyncBuilder;

impl AccountSyncBuilder {
    /// Create a new account synchronization builder.
    pub fn new<R: BackendContextBuilder + 'static>(
    /// Tries to create a new account synchronization builder.
    pub fn try_new<R: BackendContextBuilder + 'static>(
        right_builder: BackendBuilder<R>,
    ) -> Result<SyncBuilder<MaildirContextBuilder, R>> {
        let account_config = Arc::new(AccountConfig {
-- 
2.43.0
The fn returns a `Result` only because of this line:

```
let sync_dir = right_builder.account_config.get_sync_dir()?;
```

I propose instead to keep the name `new` but to pass the sync dir as
parameter, what do you think?

In both case, we introduce a breaking change.