-
Create a struct name
Setthat contains aVectorof chars and overload theminusoperator so that when 2 structs subtract it removes the chars of 2nd from 1st one. -
Create a struct named
ComplexNumberthat has 2 variablesre&imand overloadminusandplusoperator to add and subtract complex number. -
Overload the
!operator to conjugate the complex number!ComplexNumberand==and!=for comparison. -
Create a struct named
Classthat contains the class size, section and grade. Overload the>,<,>=,<=,==operators to compare class sizes of various Classes. -
Rust does not allow addition of
integerandfloat. Overload+so that this is possible. -
Implement custom
Dropfor a structHerothat contains a fieldnameof type string. Thedropshould print "Oh no !!! Our hero {name} is defeated". Run the program with just declaring a variable of typeHero. -
Create the struct named
Worldthat contains the previous named structHero, definedropfor it so that it prints "The world ends here !!!". Observe the order in whichWorldandHerocontained by it are dropped. -
Create a struct named
Tablethat has a generic fieldlegs_infoof typeT. Create a function (not a method) namedshowthat accepts function parameters&Table<Display>and displayslegs_info. Create 2 variables one that containsTof typeString: "Work in progress..."andusize: 4.
hint:use?Sized. -
Implement
Fromtrait for structComplexNumbergiven a tuple of type(isize, isize). Form it usingfromandintorespectively. -
Create a function that accepts either
ComplexNumberor(isize, isize)to return themodof ComplexNumber.