Skip to content

rename SlicePointer --> PointerIndex #92

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

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/pointer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use alloc::{
vec::Vec,
};
use core::{borrow::Borrow, cmp::Ordering, ops::Deref, str::FromStr};
use slice::SlicePointer;
use slice::PointerIndex;

mod slice;

Expand Down Expand Up @@ -320,7 +320,7 @@ impl Pointer {
/// ```
pub fn get<'p, I>(&'p self, index: I) -> Option<I::Output>
where
I: SlicePointer<'p>,
I: PointerIndex<'p>,
{
index.get(self)
}
Expand Down
18 changes: 9 additions & 9 deletions src/pointer/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ use super::Pointer;
use crate::Token;
use core::ops::Bound;

pub trait SlicePointer<'p>: private::Sealed {
pub trait PointerIndex<'p>: private::Sealed {
type Output: 'p;

fn get(self, pointer: &'p Pointer) -> Option<Self::Output>;
}

impl<'p> SlicePointer<'p> for usize {
impl<'p> PointerIndex<'p> for usize {
type Output = Token<'p>;

fn get(self, pointer: &'p Pointer) -> Option<Self::Output> {
pointer.tokens().nth(self)
}
}

impl<'p> SlicePointer<'p> for core::ops::Range<usize> {
impl<'p> PointerIndex<'p> for core::ops::Range<usize> {
type Output = &'p Pointer;

fn get(self, pointer: &'p Pointer) -> Option<Self::Output> {
Expand Down Expand Up @@ -56,7 +56,7 @@ impl<'p> SlicePointer<'p> for core::ops::Range<usize> {
}
}

impl<'p> SlicePointer<'p> for core::ops::RangeFrom<usize> {
impl<'p> PointerIndex<'p> for core::ops::RangeFrom<usize> {
type Output = &'p Pointer;

fn get(self, pointer: &'p Pointer) -> Option<Self::Output> {
Expand All @@ -81,7 +81,7 @@ impl<'p> SlicePointer<'p> for core::ops::RangeFrom<usize> {
}
}

impl<'p> SlicePointer<'p> for core::ops::RangeTo<usize> {
impl<'p> PointerIndex<'p> for core::ops::RangeTo<usize> {
type Output = &'p Pointer;

fn get(self, pointer: &'p Pointer) -> Option<Self::Output> {
Expand Down Expand Up @@ -114,15 +114,15 @@ impl<'p> SlicePointer<'p> for core::ops::RangeTo<usize> {
}
}

impl<'p> SlicePointer<'p> for core::ops::RangeFull {
impl<'p> PointerIndex<'p> for core::ops::RangeFull {
type Output = &'p Pointer;

fn get(self, pointer: &'p Pointer) -> Option<Self::Output> {
Some(pointer)
}
}

impl<'p> SlicePointer<'p> for core::ops::RangeInclusive<usize> {
impl<'p> PointerIndex<'p> for core::ops::RangeInclusive<usize> {
type Output = &'p Pointer;

fn get(self, pointer: &'p Pointer) -> Option<Self::Output> {
Expand Down Expand Up @@ -160,7 +160,7 @@ impl<'p> SlicePointer<'p> for core::ops::RangeInclusive<usize> {
}
}

impl<'p> SlicePointer<'p> for core::ops::RangeToInclusive<usize> {
impl<'p> PointerIndex<'p> for core::ops::RangeToInclusive<usize> {
type Output = &'p Pointer;

fn get(self, pointer: &'p Pointer) -> Option<Self::Output> {
Expand Down Expand Up @@ -190,7 +190,7 @@ impl<'p> SlicePointer<'p> for core::ops::RangeToInclusive<usize> {
}
}

impl<'p> SlicePointer<'p> for (Bound<usize>, Bound<usize>) {
impl<'p> PointerIndex<'p> for (Bound<usize>, Bound<usize>) {
type Output = &'p Pointer;

fn get(self, pointer: &'p Pointer) -> Option<Self::Output> {
Expand Down
Loading