Skip to content

Commit

Permalink
Improve docs on parse::int_from_string
Browse files Browse the repository at this point in the history
I only just worked on this function a week ago and already I couldn't
see from reading the code why it exists. Add a paragraph to the rustdocs
to save the next guy the trouble of working it out.
  • Loading branch information
tcharding committed Jan 20, 2025
1 parent d97cbc6 commit f1e2564
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions units/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ mod sealed {

/// Parses the input string as an integer returning an error carrying rich context.
///
/// Apart from the rich error context this function exists so that we can handle builds with and
/// without an allocator. If an allocator is available (`alloc` feature enabled) then this function
/// allocates to copy the input string into the error return. If `alloc` is not enabled the input
/// string is lost.
///
/// If the caller has a `String` or `Box<str>` which is not used later it's better to call
/// [`parse::int_from_string`] or [`parse::int_from_box`] respectively.
///
Expand Down

0 comments on commit f1e2564

Please sign in to comment.