openssh
openssh copied to clipboard
Confusing mix of references and absolutes in various function calls
I see a few types (not comprehensive though) of functions defined in the library depending on their input and output -- those with input: absolute, references, Arc -- those with output: absolute, references, Arc
Given that, I am facing issues when using reference/Arcs outputted by some functions as arguments of others that take absolutes as inputs. Here is an example
struct Some{
_session: Arc<Session>,
...
}
fn some_new() -> Some{
...
let session:Arc<session> =
Arc::new(
Session::connect(user_at_server, KnownHosts::Accept)
.await.expect("Could not connect via SSH!!")
);
..
Self{
_session: session,
...
}
fn some_other(){
...
session.clone().close();
...
}
}
....
From the above, the compiler does not likesession.clone().close()
because clone()
returns another Arc
and Session
does not implement Copy/Clone
and close()
takes an absolute self
as argument.
Is this an already discussed case, or am I missing something really obvious :) ?