Skip to content

Commit 0c75bbd

Browse files
authored
feat(toml): Expose DeInteger/DeFloat as_str/radix (#1021)
2 parents 9e7adcc + e3d64df commit 0c75bbd

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

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

Lines changed: 13 additions & 2 deletions
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<'_> {
@@ -84,7 +94,8 @@ impl DeFloat<'_> {
8494
}
8595
}
8696

87-
pub(crate) fn as_str(&self) -> &str {
97+
/// [`FromStr`][std::str::FromStr]-compatible representation of a float
98+
pub fn as_str(&self) -> &str {
8899
self.inner.as_ref()
89100
}
90101
}

0 commit comments

Comments
 (0)