Skip to content

Commit

Permalink
docs: add docs to Slice functions that can now panic
Browse files Browse the repository at this point in the history
  • Loading branch information
hiltontj committed Aug 4, 2024
1 parent fce1605 commit c851bc1
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions serde_json_path_core/src/spec/selector/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,31 @@ impl Slice {
Self::default()
}

/// Set the slice `start`
///
/// # Panics
///
/// This will panic if the provided value is outside the range [-(2<sup>53</sup>) + 1, (2<sup>53</sup>) - 1].
pub fn with_start(mut self, start: i64) -> Self {
self.start = Some(Integer::from_i64_opt(start).expect("valid start"));
self
}

/// Set the slice `end`
///
/// # Panics
///
/// This will panic if the provided value is outside the range [-(2<sup>53</sup>) + 1, (2<sup>53</sup>) - 1].
pub fn with_end(mut self, end: i64) -> Self {
self.end = Some(Integer::from_i64_opt(end).expect("valid end"));
self
}

/// Set the slice `step`
///
/// # Panics
///
/// This will panic if the provided value is outside the range [-(2<sup>53</sup>) + 1, (2<sup>53</sup>) - 1].
pub fn with_step(mut self, step: i64) -> Self {
self.step = Some(Integer::from_i64_opt(step).expect("valid step"));
self
Expand Down

0 comments on commit c851bc1

Please sign in to comment.