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

expose diffline origin value (as enum) #679

Merged

Conversation

extrawurst
Copy link
Contributor

@extrawurst extrawurst commented Mar 8, 2021

so i do not need to hardcode char's but can use actual typed enum values.

Just one question: do I have to write a wrapper enum for these things instead of exposing the one from raw?

@extrawurst extrawurst changed the title expose diffline origin value so i do not need to hardcode char's but … expose diffline origin value (as enum) Mar 8, 2021
@weihanglo
Copy link
Member

I think we should not expose raw values from libgit2 to git2 consumer. raw::git_diff_line_t is just an u32 not even a char, and exposing it won't gain supports from Rust's strong type system.

Your enum wrapper idea sounds more suitable to me for this case. 😄

@alexcrichton
Copy link
Member

Yeah if possible I think it'd be good to have a wrapper type for the return value.

@extrawurst
Copy link
Contributor Author

ok updated and wrapped in rust idiomatic enum DiffLineType. Just one thing: how do you think about the acronyms? right now I left ContextEOFNL pretty much like in libgit2. Alternative would be ContextEndOfFileNewLine 🤔

src/diff.rs Outdated Show resolved Hide resolved
@alexcrichton
Copy link
Member

Looks reasonable to me! Could you add a test exercising this as well?

@extrawurst
Copy link
Contributor Author

@alexcrichton good call, the unittest uncovered the lack of pub use the new type in lib.rs

@extrawurst extrawurst force-pushed the expose-diffline-origin-value branch from a342a6f to 09464ee Compare March 17, 2021 00:07
@alexcrichton alexcrichton merged commit ae256db into rust-lang:master Mar 18, 2021
@alexcrichton
Copy link
Member

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

Successfully merging this pull request may close these issues.

3 participants