python/
builtins.rs

1use std::fmt;
2use std::any::type_name;
3
4
5// use crate::Object;
6use crate::_Object;
7use crate::Iterable;
8
9/// print(object);
10pub fn print<T: fmt::Display>(arg: T) {
11    println!("{}", arg);
12}
13
14/// print(object);
15pub fn printd<T: fmt::Debug>(arg: T) {
16    println!("{:?}", arg);
17}
18
19
20/// print(object);
21pub fn dprint<T: fmt::Debug>(arg: T) {
22    dbg!("{}", arg);
23}
24
25/// len(object);
26pub fn len<T: Iterable>(_object: &T) -> usize {
27    _object.__len__()
28}
29
30/// repr(object);
31pub fn repr<T: _Object>(_object: &T) -> String {
32    _object.__repr__()
33}
34
35/// _str(object);
36/// sorry but i cant name this 'str'
37/// because there is a rust data type called string slice which is called
38/// guess: str
39/// that remains the convension
40pub fn _str<T: _Object>(_object: &T) -> String {
41    _object.__str__()
42}
43
44/// get the type of an object
45pub fn type_of<T>(_: &T) -> &str {
46    type_name::<T>()
47}
48
49// / the maximum from an iterable
50// pub fn max<T: Iterable>(
51//     _iterable: T,
52// ) -> Object {
53//     Object::Int32(Int::<i32>::new(123))
54// }