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

Tighten JsonPointer and methods #613

Merged
merged 1 commit into from
Sep 20, 2024
Merged

Commits on Sep 19, 2024

  1. Tighten JsonPointer and methods

    The `JsonPointer` type ought to be `#[repr(transparent)]` if
    `std::mem::transmute` is going to be used to coerce one from a `str`.
    `ReferenceToken` already did.
    
    The `validate` method did not ensure that a string starts with a `/`. This
    may not have led a direct path to any undefined behavior, because it was
    ensured that all `~` are followed by a `0` or `1`, but other methods do
    act as though they assumed a pointer string always starts with a `/`. I
    think this makes things a bit more clear.
    
    The private `token_end` can be mostly replaced by `find("/")`.
    
    `as_array_index` can be implemented in terms of the standard library's
    integer parsing. (Allowing "+000" is an annoying gotcha in seemingly
    every major language's standard library!).
    
    I've added `Deserialize` for `&JsonPointer`.
    
    I've made the internals of the new `json_pointer!` macro `const {}` to
    better ensure that its checks actually happen at compile time.
    
    I've adjusted some methods to reduce the total number of `unsafe` blocks
    necessary.
    jeddenlea committed Sep 19, 2024
    Configuration menu
    Copy the full SHA
    f5b0079 View commit details
    Browse the repository at this point in the history