Skip to content

Dataset::rasterband doesn't follow Rust mutable reference rules. #450

Open
@metasim

Description

Currently, the following compiles, but the test fails:

#[test]
fn test_mut() {
    let dataset = Dataset::open(fixture("tinymarble.tif")).unwrap();
    let b1 = dataset.rasterband(1).unwrap();
    let before_desc = b1.description().unwrap();

    {
        let mut also_b1 = dataset.rasterband(1).unwrap();
        // Arbitrary mutation
        also_b1.set_description("smash").unwrap();
    }

    let after_desc = b1.description().unwrap();

    assert_eq!(before_desc, after_desc);
}

Given we never request a mutable reference to Dataset, one could argue you should never be able to get a mutable reference to an owned, constituent component of the Dataset, as we have done here.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions