Skip to content

Commit

Permalink
rename SlicePointer --> PointerIndex (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
asmello authored Oct 22, 2024
1 parent c694765 commit 5c81e47
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
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

0 comments on commit 5c81e47

Please sign in to comment.