-
Create a struct name
Set
that contains aVector
of chars and overload theminus
operator so that when 2 structs subtract it removes the chars of 2nd from 1st one. -
Create a struct named
ComplexNumber
that has 2 variablesre
&im
and overloadminus
andplus
operator to add and subtract complex number. -
Overload the
!
operator to conjugate the complex number!ComplexNumber
and==
and!=
for comparison. -
Create a struct named
Class
that contains the class size, section and grade. Overload the>
,<
,>=
,<=
,==
operators to compare class sizes of various Classes. -
Rust does not allow addition of
integer
andfloat
. Overload+
so that this is possible. -
Implement custom
Drop
for a structHero
that contains a fieldname
of type string. Thedrop
should print "Oh no !!! Our hero {name} is defeated". Run the program with just declaring a variable of typeHero
. -
Create the struct named
World
that contains the previous named structHero
, definedrop
for it so that it prints "The world ends here !!!". Observe the order in whichWorld
andHero
contained by it are dropped. -
Create a struct named
Table
that has a generic fieldlegs_info
of typeT
. Create a function (not a method) namedshow
that accepts function parameters&Table<Display>
and displayslegs_info
. Create 2 variables one that containsT
of typeString: "Work in progress..."
andusize: 4
.
hint:
use?Sized
. -
Implement
From
trait for structComplexNumber
given a tuple of type(isize, isize)
. Form it usingfrom
andinto
respectively. -
Create a function that accepts either
ComplexNumber
or(isize, isize)
to return themod
of ComplexNumber.