Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hard to resolve error "set: Cannot mutate immutable Rc articulation; use an DCG cell instead" #10

Open
Cypher1 opened this issue Jun 18, 2023 · 0 comments

Comments

@Cypher1
Copy link

Cypher1 commented Jun 18, 2023

Attempting to get a test working with the following code.

Not sure how to get the re-use and incremental compute working and I'm unsure of what the error message means (this is my first time using adapton).

Code sample:

    #[test]
    fn test_adapton_parser_pair() -> Result<(), TError> {
        use adapton::*;
        use std::sync::{Arc, Mutex};

        let calls = Arc::new(Mutex::new(0));
        let counter = calls.clone();
        let input = cell!([input] "1,2");
        let ast = thunk!([ast]
            |src: &str| {
                *counter.lock().unwrap() += 1;
                setup(src)
            };
            src: get!(input)
        );
        {
            set(&input, "1,2");
            let ast = get!(ast)?;
            assert_eq!(ast.identifiers.len(), 0);
            assert_eq!(ast.literals.len(), 2);
            assert_eq!(ast.ops.len(), 1);
            assert_eq!(ast.definitions.len(), 0);
            assert_eq!(*calls.lock().unwrap(), 1);
        }
        {
            set(&input, "1,2,3");
            let ast = get!(ast)?;
            assert_eq!(ast.identifiers.len(), 0);
            assert_eq!(ast.literals.len(), 3);
            assert_eq!(ast.ops.len(), 2);
            assert_eq!(ast.definitions.len(), 0);
            assert_eq!(*calls.lock().unwrap(), 2);
        }
        {
            set(&input, "1,2");
            let ast = get!(ast)?;
            assert_eq!(ast.identifiers.len(), 0);
            assert_eq!(ast.literals.len(), 2);
            assert_eq!(ast.ops.len(), 1);
            assert_eq!(ast.definitions.len(), 0);
            assert_eq!(*calls.lock().unwrap(), 2);
        }
        Ok(())
    }

Would love some help with this as I'm fairly certain that I'm following the Adapton documentation (here: https://docs.rs/adapton/0.3.31/adapton/ ) fairly closely.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant