Value of the last expression in evcxr?

⚓ Rust    📅 2025-11-16    👤 surdeus    👁️ 8      

surdeus

Hello. Is there a way to get value of the last expression evaluated by evcxr?

This works great:

>> fn test() -> String {
    "hello".to_string()
}
let result = test();

>> result
"hello"

Or this:

>> let result = {
    fn test() -> String {
        "hello".to_string()
    }
    test()
};

>> result
"hello"

But I'd like to be able to do this:

>> fn test() -> String {
    "hello".to_string()
}
test()
"hello"

>> let result = ...???...;
>> result
"hello"

Can't find this in the docs. Is this possible?

1 post - 1 participant

Read full topic

🏷️ Rust_feed