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

Inconsistent mutable reference tracking in vector module. #448

Open
metasim opened this issue Oct 3, 2023 · 0 comments
Open

Inconsistent mutable reference tracking in vector module. #448

metasim opened this issue Oct 3, 2023 · 0 comments

Comments

@metasim
Copy link
Contributor

metasim commented Oct 3, 2023

The following methods mutate the underlying C types but do not require a mutable reference in Rust.

  • LayerAccess::create_defn_fields
  • LayerAccess::set_feature
  • FieldDefn::set_width
  • FieldDefn::set_precision
  • Feature::set_field_string
  • Feature::set_field_string_list
  • Feature::set_field_double
  • Feature::set_field_double_list
  • Feature::set_field_integer
  • Feature::set_field_integer64
  • Feature::set_field_integer64_list
  • Feature::set_field_datetime
  • Feature::set_field

Also:

  • FieldDefn::add_to_layer mutates the layer parameter
  • Feature::create mutates lyr parameter

This means the following code compiles, but shouldn't under Rust ownership rules:

#[test]
fn multiple_mutable_references() {
    let f = FieldDefn::new("foo", OGRFieldType::OFTInteger).unwrap();

    let f1 = &f;
    let f2 = &f;

    f1.set_width(10);
    f2.set_width(20);
}
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