Skip to content

feat: RAII wrapper for ProjArea - #262

Open
y1lan wants to merge 1 commit into
georust:mainfrom
y1lan:yanglin/fix/proj-area-raii
Open

feat: RAII wrapper for ProjArea#262
y1lan wants to merge 1 commit into
georust:mainfrom
y1lan:yanglin/fix/proj-area-raii

Conversation

@y1lan

@y1lan y1lan commented Sep 7, 2026

Copy link
Copy Markdown

The normal manually destroy calling cannot cover the error path, which
is different from C language where every path is explicitly noted by
human.

RAII Wapper would help compiler to insert the drop glue correctly.

Pick test test_from_crs_error as an entry point:

#[test]
fn test_from_crs_error() {
    match Proj::new_known_crs("EPSG:4326", "🦀", None) {
        Err(ProjCreateError::ProjError(..)) => (),
        _ => unreachable!(),
    }

    match Proj::new_known_crs("🦀", "EPSG:4326", None) {
        Err(ProjCreateError::ProjError(..)) => (),
        _ => unreachable!(),
    }
}

function transform_epsg would early return, but the resource created by proj_area_create is not released.

similar problem happens on function crs_to_crs_from_pj.

  • I agree to follow the project's code of conduct.
  • I added an entry to the project's change log file if knowledge of this change could be valuable to users.
    • Usually called CHANGES.md or CHANGELOG.md
    • Prefix changelog entries for breaking changes with "BREAKING: "

The normal manually destroy calling cannot cover the error path, which
is different from C language where every path is explicitly noted by
human.

RAII Wapper would help compiler to insert the drop glue correctly
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

Successfully merging this pull request may close these issues.

1 participant