diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-01-04 21:29:15 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-01-04 21:29:15 +0100 |
| commit | 2e77b1c836220766398e379ae0157736fb448874 (patch) | |
| tree | 70fc7d28f44193f26d880b5315ce55ed951af73c /src/library/extend.rs | |
| parent | 77c06ebc24ab3a43dc2268763ff8f10963f875b4 (diff) | |
Better value representations, type function 🌐
Diffstat (limited to 'src/library/extend.rs')
| -rw-r--r-- | src/library/extend.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/library/extend.rs b/src/library/extend.rs new file mode 100644 index 00000000..e388c9c8 --- /dev/null +++ b/src/library/extend.rs @@ -0,0 +1,16 @@ +use crate::prelude::*; + +/// `type`: Find out the name of a value's type. +/// +/// # Positional arguments +/// - Any value. +/// +/// # Return value +/// The name of the value's type as a string. +pub fn type_(ctx: &mut EvalContext, args: &mut Args) -> Value { + if let Some(value) = args.require::<Value>(ctx, "value") { + value.type_name().into() + } else { + Value::Error + } +} |
