Skip to content
This repository was archived by the owner on Apr 2, 2026. It is now read-only.
Merged
Changes from 1 commit
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
5 changes: 4 additions & 1 deletion src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1704,9 +1704,12 @@ impl<'src, 'parse, I: Input<'src>, E: ParserExtra<'src, I>> InputRef<'src, 'pars
let _ = self.next_inner();
}

/// Get full slice of raw input.
///
/// Note we have to make sure our index of full slice land in the correct boundary of utf8 character if using utf8 input.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I'm not sure that I understand what this note is trying to say, could you clarify?

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.

For example, if the slice of raw input is &str,

  let s: &str = "你好"; // for utf8 character, non ascii character
  // OK
  let a = &s[0..3];
  println!("{}", a);

  // panic since 1 is not the right byte boundary of utf8 char <--------------
  let a = &s[1..3];
  println!("{}", a);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

There is no particular notion of 'boundaries' built into SliceInput, that's purely a function of &str. I don't think this is worth mentioning in this doc comment.

I am not sure what 'our index of full slice' refers to in the comment either: the method has no parameters?

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.

You are right. I have removed the unclear and unnecessary lines in the comments.

#[cfg_attr(not(feature = "regex"), allow(dead_code))]
#[inline]
pub(crate) fn full_slice(&mut self) -> I::Slice
pub fn full_slice(&mut self) -> I::Slice
where
I: SliceInput<'src>,
{
Expand Down