Skip to content

Change client::*::from_stub() should accept Into<Arc<T>> #2146

@coryan

Description

@coryan

This is a non-breaking change to make the from_stub constructor for client. We can make it more usable if it accepts Into<Arc<T>>:

use std::sync::Arc;

pub struct Foo<T> {
    inner: Arc<T>
}

impl<T> Foo<T> {
    pub fn from<U>(v: U) -> Self 
    where U: Into<Arc<T>> {
        Self { inner: v.into() }
    }
    
    pub fn use_inner(&self) -> T where T: Clone {
        (*self.inner).clone()
    }
}

pub fn from_str(a: String) -> Foo<String> {
    Foo::from(a)
}

pub fn from_arc(a: Arc<String>) -> Foo<String> {
    Foo::from(a)
}

Metadata

Metadata

Assignees

Labels

priority: p3Desirable enhancement or fix. May not be included in next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions