Skip to content

Add data_loc method to Rust bindings - #2854

Merged
kddnewton merged 2 commits into
ruby:mainfrom
ryym:add-data-loc-to-rust-bindings
Jun 3, 2024
Merged

kddnewton merged 2 commits into
ruby:mainfrom
ryym:add-data-loc-to-rust-bindings

Conversation

@ryym

@ryym ryym commented Jun 1, 2024

Copy link
Copy Markdown
Contributor

Closes #2621

Currently Prism recognizes the __END__ content and provides a way to access it in Ruby, C, and Java APIs, but Rust bindings does not have it. This PR adds the data_loc method to Rust API.

which returns a location of the __END__ content.
Comment thread rust/ruby-prism/src/lib.rs Outdated
pub fn data_loc(&self) -> Option<Location<'_>> {
let root = self.source.as_ptr();
let location = unsafe { &(*self.parser.as_ptr()).data_loc };
if location.start >= root {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In other optional locations we're checking start.is_null() instead, can you do that here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, I changed the implementation to use is_null() .
be34f68

@ryym
ryym requested a review from kddnewton June 2, 2024 00:54
@kddnewton
kddnewton merged commit 99b2303 into ruby:main Jun 3, 2024
@ryym
ryym deleted the add-data-loc-to-rust-bindings branch July 27, 2024 00:27
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.

2 participants