W
W
WasTabon2022-01-23 18:42:01
Rust
WasTabon, 2022-01-23 18:42:01

What does -> mean in Rust?

fn main(){
    let message = get_message();
    println!("message: {}", message);
}
 
fn get_message<'a>() -> &'a str {
    "hello"
}

Here in this code, for example, fn get_message<'a>() -> &'a str why, when and why is -> used?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Lesnikov, 2022-01-23
@WasTabon

Rustbook: "Functions that return values" is just part of the syntax of rusty functions, which is used when you need to explicitly indicate the return type.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question