Arc usage with traits


I’m getting a bit confused how Arc is handled in my situation.
I calling serving function with Arc to my struct as such:

    let storage = storage.clone();

    io.add_method("emerald_unhideAccount", move |p: Params| {
        wrapper(serves::unhide_account(parse(p)?, &storage))

pub fn unhide_account<T>(
    params: Either<(UnhideAccountAccount,), (UnhideAccountAccount, CommonAdditional)>,
    storage: &Arc<T>,
) -> Result<bool, Error>
    T: KeyfileStorage,

It compiles now, but I wonder why when there was PathBuf wrapped inside Arc one doesn’t need to specify &Arc<> for unhide_account fuction, just &PathBuf worked ?


More details of your code/fn signatures would be helpful.

My guess, based on what you wrote, is that PathBuf has no references, and thus has a 'static bound - you can safely moveit to another thread. When you switch to a generic T:KeyfileStorage that is no longer the case, necessarily, because you can implement that trait for just about anything, including references or types that have references. It would seem you can avoid the Arc as well, then, by using constraint T: KeyfileStorage + 'static. But it’s hard to say more without seeing more of your code.