trait
Roundable
The Roundable
trait describes a type that defines a rounding operation.
Types that conform to Roundable
will work with the builtin round
function. The round operation always returns the same type as the input.
For example:
@value
struct Complex(Roundable):
var re: Float64
var im: Float64
fn __round__(self) -> Self:
return Self(round(re), round(im))
Implemented traits
AnyType
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!
If you'd like to share more information, please report an issue on GitHub
😔 What went wrong?