Using unsafe 관련 글(The Rustonomicon=unsafe설명서Rust) -Reddit-learnrust
Using unsafe to borrow *self as mutable more than once?
So I have a the following situation, where I am calling two methods inside a struct that borrow self as mutable
if let Some(list_item) = self.selected_item_mut(){
if let Some(item) = self.get_item_in_tree_mut(list_item){
<code snipped>
Then I get the "cannot borrow `*self` as mutable more than once at a time".
So then I thought I'd try some unsafe code?
unsafe{
if let Some(list_item) = self.selected_item_mut(){
if let Some(item) = self.get_item_in_tree_mut(list_item){
<code snipped>
}
But then I get the same error along with "unnecessary unsafe block"
Any help appreciated!
edit: I guess what I'm really trying to do is access two different data structures inside the struct, but I can't borrow self as both immutable and mutable, and can't borrow it as mutable twice, and I need a mutable reference to the object inside the second data structure.
Rust
Unsafe 지침서
Nomicon
https://doc.rust-lang.org/nomicon/index.html