Skip to content

Commit ffdd211

Browse files
committed
feat(toml): Expose DeInteger::as_str/radix
1 parent da667e8 commit ffdd211

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

crates/toml/src/de/parser/devalue.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,19 @@ impl DeInteger<'_> {
3535
i128::from_str_radix(self.inner.as_ref(), self.radix).ok()
3636
}
3737

38-
pub(crate) fn as_str(&self) -> &str {
38+
/// [`from_str_radix`][i64::from_str_radix]-compatible representation of an integer
39+
///
40+
/// Requires [`DeInteger::radix`] to interpret
41+
///
42+
/// See [`Display`][std::fmt::Display] for a representation that includes the radix
43+
pub fn as_str(&self) -> &str {
3944
self.inner.as_ref()
4045
}
46+
47+
/// Numeric base of [`DeInteger::as_str`]
48+
pub fn radix(&self) -> u32 {
49+
self.radix
50+
}
4151
}
4252

4353
impl Default for DeInteger<'_> {

0 commit comments

Comments
 (0)