Skip to main content

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?