Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct Context<'a> {
- base: Option<&'a mut Context<'a>>,
- v: &'a mut u32,
- }
- fn ent<'a: 'b, 'b>(context: &'a mut Context<'b>, v: u32) -> &'a mut u32 {
- let mut current_context = context;
- loop {
- if *current_context.v == v {
- break &mut current_context.v;
- }
- if let Some(base_context) = &mut current_context.base {
- current_context = base_context;
- } else {
- panic!("Entity not found.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement