Ask Your Question
1

Is it observed that the borrow checker considers Rust function pointer to have statefulness?

asked 2022-07-16 11:00:00 +0000

plato gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2021-07-08 02:00:00 +0000

nofretete gravatar image

No, the borrow checker does not consider Rust function pointers to have statefulness. Function pointers in Rust are considered to be stateless, meaning that they don't have any internal state that can be mutated or changed. The borrow checker only checks the borrow and ownership rules for data types that have mutable state, such as references or mutable data structures. Function pointers are simply a reference to a specific function in memory, and as such, do not have any borrow or ownership semantics that need to be checked by the borrow checker.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-07-16 11:00:00 +0000

Seen: 8 times

Last updated: Jul 08 '21