Skip to content

Commit

Permalink
Add hint to IntegerLit::value docs
Browse files Browse the repository at this point in the history
CC #15
  • Loading branch information
LukasKalbertodt committed Oct 18, 2023
1 parent bd6fae1 commit ba46f30
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/integer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ impl<B: Buffer> IntegerLit<B> {
/// method**. This means `N` does not need to match the type suffix!
///
/// Returns `None` if the literal overflows `N`.
///
/// Hint: `u128` can represent all possible values integer literal values,
/// as there are no negative literals (see type docs). Thus you can, for
/// example, safely use `lit.value::<u128>().to_string()` to get a decimal
/// string. (Technically, Rust integer literals can represent arbitrarily
/// large numbers, but those would be rejected at a later stage by the Rust
/// compiler).
pub fn value<N: FromIntegerLiteral>(&self) -> Option<N> {
let base = N::from_small_number(self.base.value());

Expand Down

0 comments on commit ba46f30

Please sign in to comment.