Firstly, the signature of an element is just a bit that gives the name and types of your function, that is, everything you need to call (without having to know how it is implemented); eg:
fn foo(x: u32) -> u32;
Here is another that accepts the link &str:
fn bar<'a>(s: &'a str) -> &'a str;
Rust, ; . bar , " ". : " , , . Rust.
, , , Rust " elision" (.. " " ). , () , Rust . , "" .
, :
fn f(x: &T, y: &U)
:
fn f<'a, 'b>(x: &'a T, y: &'b U)
.. .
- , . :
struct U<'a> {} // struct with a lifetime parameter
fn f(x: &T) -> &U
:
fn f<'a>(x: &'a T) -> &'a U<'a>
- , , -
&self &mut self (.. ), , self. , . , :
impl S {
fn get_my_item(&self, key: &str) -> &str {}
}
:
fn get_my_item<'a,'b>(&'a self, key: &'b str) -> &'a str // use the self lifetime
.