Wellknown traits
Some Rust traits from standard library has special support or effect in Zngur. They are listed in this page. You can use
them by adding wellknown_traits(Trait1, Trait2);
statement for your type in main.zng
file.
Copy
Adding this trait enables copy constructor for the type in the C++ side, and removes the drop flag and destructor related generated codes, so it will improve the performance.
?Sized
Marks the type as unsized and the pointers to them as fat. Unlike other wellknown traits, this is mandatory and missing it for a type will result in a compile error.
Debug
Enables using zngur_dbg
macro for a type. zngur_dbg
is a macro similar to dbg!
in Rust which prints the location, name
and value of expression inside it, like this:
[main.cpp:64] t = [
10,
20,
60,
]
and returns it for further use.
PartialEq, PartialOrd, Add, Sub, Mul, Div, Rem, BitAnd, BitOr, BitXor, Shl, Shr
Unimplemented: This feature is not implemented yet. The progress in tracked in the issue https://github.com/HKalbasi/zngur/issues/2. Feel free to express your interest so that it will be prioritized and consider contributing if you can.
These traits add operator overloading for binary operators ==
, <=>
, +
, -
, *
, /
, %
, &
, |
, ^
, <<
and >>
respectively.
IntoIterator
Unimplemented: This feature is not implemented yet. The progress in tracked in the issue https://github.com/HKalbasi/zngur/issues/2. Feel free to express your interest so that it will be prioritized and consider contributing if you can.
Enables converting the type into a C++ iterable object, so you can use it in for (auto x: iterator)
and standard library functions
that expect an iterator.