Skip to content
This repository was archived by the owner on Sep 10, 2024. It is now read-only.
This repository was archived by the owner on Sep 10, 2024. It is now read-only.

Functional purification for Cell and other types with interior mutability #4

@tyrbentsen

Description

@tyrbentsen

Could you elaborate on whether functional purification can still hold when using types with interior mutability, like 'Cell'?

In the following example, c2 is mutated through c1. Is there any rule that can be used to transform this into a purely functional equivalent (without having to track all the aliases to c1, which might be difficult for non-trivial cases)?

let c1: &Cell<i32> = &Cell::new(0);
let c2: &Cell<i32> = c1;
c1.set(2);
println!("{:?}", c2.get()); // Prints 2

What about RefCell, Mutex, ... ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions