Skip to content

Commit ba46f30

Browse files
Add hint to IntegerLit::value docs
CC #15
1 parent bd6fae1 commit ba46f30

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/integer/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ impl<B: Buffer> IntegerLit<B> {
6060
/// method**. This means `N` does not need to match the type suffix!
6161
///
6262
/// Returns `None` if the literal overflows `N`.
63+
///
64+
/// Hint: `u128` can represent all possible values integer literal values,
65+
/// as there are no negative literals (see type docs). Thus you can, for
66+
/// example, safely use `lit.value::<u128>().to_string()` to get a decimal
67+
/// string. (Technically, Rust integer literals can represent arbitrarily
68+
/// large numbers, but those would be rejected at a later stage by the Rust
69+
/// compiler).
6370
pub fn value<N: FromIntegerLiteral>(&self) -> Option<N> {
6471
let base = N::from_small_number(self.base.value());
6572

0 commit comments

Comments
 (0)