Public API and docs

This commit is contained in:
2023-05-26 15:23:15 +01:00
parent 3c1a6e2be2
commit fdf18e6ff8
99 changed files with 503 additions and 406 deletions

32
src/stl/conv/to_string.rs Normal file
View File

@@ -0,0 +1,32 @@
use std::fmt::Debug;
use super::super::litconv::with_lit;
use crate::representations::interpreted::ExprInst;
use crate::representations::Literal;
use crate::{atomic_impl, atomic_redirect, externfn_impl};
/// Convert a literal to a string using Rust's conversions for floats, chars and
/// uints respectively
///
/// Next state: [ToString0]
#[derive(Clone)]
pub struct ToString1;
externfn_impl!(ToString1, |_: &Self, x: ExprInst| Ok(ToString0 { x }));
/// Prev state: [ToString1]
#[derive(Debug, Clone)]
pub struct ToString0 {
x: ExprInst,
}
atomic_redirect!(ToString0, x);
atomic_impl!(ToString0, |Self { x }: &Self, _| {
let string = with_lit(x, |l| {
Ok(match l {
Literal::Char(c) => c.to_string(),
Literal::Uint(i) => i.to_string(),
Literal::Num(n) => n.to_string(),
Literal::Str(s) => s.clone(),
})
})?;
Ok(string.into())
});