I'm a rust beginner, and this is not a blocking point but is of interest in my learning.
I defined a trait AsfaloadKeyPair which defines a method new. I implemented the trait for minisign::KeyPair so I can call
let kp = minisign::KeyPair::new("mypass")?.save(temp_file_path)?;
I'm wondering if there's a way to call new from the AsfaloadKeyPair trait itself, like:
let kp: &minisign::KeyPair = AsfaloadKeyPair::new("mypass")?.save(temp_file_path)?;
But this doesn't work as it asks for a type annotation on AsfaloadKeyPair::new("mypass")?. How do you give this expression a type annotation?
what do you mean by "from the trait itself"? if you are defining the default implementation for some of the trait method, you can use Self::new, or <Self as AsfaloadKeyPair>::new.