Can I pass mutable reference as immutable?


#1

I got an type error by following code.

fn a(r: &SomeStruct) {}
fn b(r: &mut SomeStruct) {
    a(r);
}

I think that this is no problems in view point of bollowing.
How can I solve it?


#2

This code compiles fine on the playpen:

struct SomeStruct;
fn a(r: &SomeStruct) {}
fn b(r: &mut SomeStruct) {
    a(r);
}

fn main() {}

Could you create an self-contained example that fails to compile with the error you’re actually having trouble with?


#3

Sorry, it was my misunderstanding about error.