#rectangle #area #perimeter #traits #impl #struct

MathTriks

A single crate for every mathematical manipulation

1 unstable release

0.1.0 Dec 18, 2023

#1146 in Math

Apache-2.0

25KB
151 lines

// struct Rectangle{ // length:i32, // width:i32, // } // trait Info{ // fn area(&self); // fn perimeter(&self); // } // impl Info for Rectangle{ // fn area(&self) { // let teja=self.length*self.width; // println!("{:?}",teja);

// } // fn perimeter(&self) { // let teja=2*(self.length*self.width); // println!("{:?}",teja);

// } // } // fn main(){ // let san=Rectangle{ // length:10, // width:5, // }; // san.area(); // san.perimeter(); // }

// void type

// fn main() {
//     let san=Rectangle {
//         length:10,
//         width:5,
//     };
//     san.area();
//     san.perimeter();
// }

// struct Rectangle {
//     length:i32,
//     width:i32,
// }
// trait Info {
//     fn area (&self);
//     fn perimeter(&self);
// }
// impl Info for Rectangle {
//     fn area (&self) {
//         let teja=self.length*self.width;
//         println!("{}",teja);
//     }
//     fn perimeter (&self) {
//         let teja=2*(self.length*self.width);
//         println!("{}",teja);
//     }
// }

// return type // struct Circle{ // radius:f64, // } // struct Square{ // side:f64, // } // trait Info{ // fn area(&self) ->f64; // fn perimeter(&self) ->f64; // } // impl Info for Circle{ // fn area(&self) ->f64 { // let a= 3.14*(self.radiusself.radius); // a // } // fn perimeter(&self) ->f64{ // let b=2.03.14self.radius; // b // } // } // impl Info for Square{ // fn area(&self) ->f64 { // let c= self.sideself.side; // c // } // fn perimeter(&self) ->f64{ // let d=4.0*self.side; // d // } // } // fn main(){ // let san=Circle{ // radius:10.0 // }; // let man=Square{ // side:7.5 // }; // let x=san.area(); // let y=san.perimeter(); // let z=man.area(); // let n=man.perimeter(); // println!("{:?},{:?},{:?},{:?}",x,y,z,n); // } // print aadhar information using structure

// structure declaration // struct Aadhar { // name: String, // age: u32, // gender: String, // mobile_num: String, // email: String, // dob: String, // address:String, // }

// // trait declaration // trait PrintAadharDetails { // fn print_details(&self); // }

// // Implement traits for structure // impl PrintAadharDetails for Aadhar { // fn print_details(&self) { // println!("Aadhar Details:"); // println!("Name: {}", self.name); // println!("Age: {}", self.age); // println!("Gender: {}", self.gender); // println!("Mobile Number: {}", self.mobile_num); // println!("Email Address: {}", self.email); // println!("Date of Birth: {}", self.dob); // println!("Address: {}", self.address); // } // }

// fn main() {

// let aadhar = Aadhar { // name: String::from("teju"), // age: 30, // gender: String::from("feMale"), // mobile_num: String::from("1234567890"), // email: String::from("teju@gmail.com"), // dob: String::from("1999-08-19"), // address: String::from("kajaguda cross road,gachibowli"), // };

// aadhar.print_details(); // } // print aadhar information using structure

// structure declaration struct Aadhar { name: String, age: u32, gender: String, mobile_num: i64, email: String, dob: u32, address:String, } // trait declaration trait PrintAadharDetails { fn name(&self) ->&str; fn age(&self) ->u32; fn gender(&self) ->&str; fn mobile_num(&self) ->i64; fn email(&self) ->&str; fn dob(&self) ->u32; fn address(&self) ->&str;

} impl PrintAadharDetails for Aadhar{ fn name(&self) ->&str { &self.name } fn age(&self) ->u32 { self.age } fn gender(&self) ->&str { &self.gender } fn mobile_num(&self) ->i64 { self.mobile_num// struct Rectangle{ // length:i32, // width:i32, // } // trait Info{ // fn area(&self); // fn perimeter(&self); // } // impl Info for Rectangle{ // fn area(&self) { // let teja=self.length*self.width; // println!("{:?}",teja);

        //     }
        //     fn perimeter(&self) {
        //         let teja=2*(self.length*self.width);
        //         println!("{:?}",teja);
        
        //     }
        // }
        // fn main(){
        //         let san=Rectangle{
        //             length:10,
        //             width:5,
        //         };
        //         san.area();
        //         san.perimeter();
        //     }
        
        // void type
        
            // fn main() {
            //     let san=Rectangle {
            //         length:10,
            //         width:5,
            //     };
            //     san.area();
            //     san.perimeter();
            // }
            
            // struct Rectangle {
            //     length:i32,
            //     width:i32,
            // }
            // trait Info {
            //     fn area (&self);
            //     fn perimeter(&self);
            // }
            // impl Info for Rectangle {
            //     fn area (&self) {
            //         let teja=self.length*self.width;
            //         println!("{}",teja);
            //     }
            //     fn perimeter (&self) {
            //         let teja=2*(self.length*self.width);
            //         println!("{}",teja);
            //     }
            // }
        // return type
        // struct Circle{
        //     radius:f64,
        // }
        // struct Square{
        //     side:f64,
        // }
        // trait Info{
        //     fn area(&self) ->f64;
        //     fn perimeter(&self) ->f64;
        // }
        // impl Info for Circle{
        //     fn area(&self) ->f64 {
        //         let a= 3.14*(self.radius*self.radius);
        //         a
        //     }
        //     fn perimeter(&self) ->f64{
        //         let b=2.0*3.14*self.radius;
        //         b
        //     }
        // }
        // impl Info for Square{
        //     fn area(&self) ->f64 {
        //         let c= self.side*self.side;
        //         c
        //     } 
        //     fn perimeter(&self) ->f64{
        //         let d=4.0*self.side;
        //         d
        //     }
        // }
        // fn main(){
        //     let san=Circle{
        //         radius:10.0
        //     };
        //     let man=Square{
        //         side:7.5
        //     };
        //     let x=san.area();
        //     let y=san.perimeter();
        //     let z=man.area();
        //     let n=man.perimeter();
        //     println!("{:?},{:?},{:?},{:?}",x,y,z,n);
        // }
        // print aadhar information using structure
        
        // structure declaration
        // struct Aadhar {
        //     name: String,
        //     age: u32,
        //     gender: String,
        //     mobile_num: String,
        //     email: String,
        //     dob: String,
        //     address:String,
        // }
        
        // // trait declaration
        // trait PrintAadharDetails {
        //     fn print_details(&self);
        // }
        
        // // Implement traits for structure
        // impl PrintAadharDetails for Aadhar {
        //     fn print_details(&self) {
        //         println!("Aadhar Details:");
        //         println!("Name: {}", self.name);
        //         println!("Age: {}", self.age);
        //         println!("Gender: {}", self.gender);
        //         println!("Mobile Number: {}", self.mobile_num);
        //         println!("Email Address: {}", self.email);
        //         println!("Date of Birth: {}", self.dob);
        //         println!("Address: {}", self.address);
        //     }
        // }
        
        // fn main() {
            
        //     let aadhar = Aadhar {
        //         name: String::from("teju"),
        //         age: 30,
        //         gender: String::from("feMale"),
        //         mobile_num: String::from("1234567890"),
        //         email: String::from("teju@gmail.com"),
        //         dob: String::from("1999-08-19"),
        //         address: String::from("kajaguda cross road,gachibowli"),
        //     };
        
            
        //     aadhar.print_details();
        // }
        //  print aadhar information using structure
        
        // structure declaration
        struct Aadhar {
            name: String,
            age: u32,
            gender: String,
            mobile_num: i64,
            email: String,
            dob: u32,
            address:String,
        }
        //  trait declaration
        trait PrintAadharDetails  {
            fn name(&self) ->&str;
            fn age(&self) ->u32;
            fn gender(&self) ->&str;
            fn mobile_num(&self) ->i64;
            fn email(&self) ->&str;
            fn dob(&self) ->u32;
            fn address(&self) ->&str;
        
        }
        impl PrintAadharDetails for Aadhar{
            fn name(&self) ->&str {
                &self.name
            }// struct Rectangle{

// length:i32, // width:i32, // } // trait Info{ // fn area(&self); // fn perimeter(&self); // } // impl Info for Rectangle{ // fn area(&self) { // let teja=self.length*self.width; // println!("{:?}",teja);

// } // fn perimeter(&self) { // let teja=2*(self.length*self.width); // println!("{:?}",teja);

// } // } // fn main(){ // let san=Rectangle{ // length:10, // width:5, // }; // san.area(); // san.perimeter(); // }

// void type

// fn main() {
//     let san=Rectangle {
//         length:10,
//         width:5,
//     };
//     san.area();
//     san.perimeter();
// }

// struct Rectangle {
//     length:i32,
//     width:i32,
// }
// trait Info {
//     fn area (&self);
//     fn perimeter(&self);
// }
// impl Info for Rectangle {
//     fn area (&self) {
//         let teja=self.length*self.width;
//         println!("{}",teja);
//     }
//     fn perimeter (&self) {
//         let teja=2*(self.length*self.width);
//         println!("{}",teja);
//     }
// }

// return type // struct Circle{ // radius:f64, // } // struct Square{ // side:f64, // } // trait Info{ // fn area(&self) ->f64; // fn perimeter(&self) ->f64; // } // impl Info for Circle{ // fn area(&self) ->f64 { // let a= 3.14*(self.radiusself.radius); // a // } // fn perimeter(&self) ->f64{ // let b=2.03.14self.radius; // b // } // } // impl Info for Square{ // fn area(&self) ->f64 { // let c= self.sideself.side; // c // } // fn perimeter(&self) ->f64{ // let d=4.0*self.side; // d // } // } // fn main(){ // let san=Circle{ // radius:10.0 // }; // let man=Square{ // side:7.5 // }; // let x=san.area(); // let y=san.perimeter(); // let z=man.area(); // let n=man.perimeter(); // println!("{:?},{:?},{:?},{:?}",x,y,z,n); // } // print aadhar information using structure

// structure declaration // struct Aadhar { // name: String, // age: u32, // gender: String, // mobile_num: String, // email: String, // dob: String, // address:String, // }

// // trait declaration // trait PrintAadharDetails { // fn print_details(&self); // }

// // Implement traits for structure // impl PrintAadharDetails for Aadhar { // fn print_details(&self) { // println!("Aadhar Details:"); // println!("Name: {}", self.name); // println!("Age: {}", self.age); // println!("Gender: {}", self.gender); // println!("Mobile Number: {}", self.mobile_num); // println!("Email Address: {}", self.email); // println!("Date of Birth: {}", self.dob); // println!("Address: {}", self.address); // } // }

// fn main() {

// let aadhar = Aadhar { // name: String::from("teju"), // age: 30, // gender: String::from("feMale"), // mobile_num: String::from("1234567890"), // email: String::from("teju@gmail.com"), // dob: String::from("1999-08-19"), // address: String::from("kajaguda cross road,gachibowli"), // };

// aadhar.print_details(); // } // print aadhar information using structure

// structure declaration struct Aadhar { name: String, age: u32, gender: String, mobile_num: i64, email: String, dob: u32, address:String, } // trait declaration trait PrintAadharDetails { fn name(&self) ->&str; fn age(&self) ->u32; fn gender(&self) ->&str; fn mobile_num(&self) ->i64; fn email(&self) ->&str; fn dob(&self) ->u32; fn address(&self) ->&str;

} impl PrintAadharDetails for Aadhar{ fn name(&self) ->&str { &self.name } fn age(&self) ->u32 { self.age } fn gender(&self) ->&str { &self.gender } fn mobile_num(&self) ->i64 { self.mobile_num } fn email(&self) ->&str { &self.email } fn dob(&self) ->u32 { self.dob } fn address(&self) ->&str { &self.address }

} fn main() { let b= Aadhar{ name:String::from("Teja"), gender:String::from("Female"), mobile_num:9100631674, email:String::from("teju@gmail.com"), dob:10_09_1879, age:16, address:String::from("Mounika"), }; println!("{:?},{:?},{:?},{:?},{:?},{:?},{:?}",b.name,b.gender,b.mobile_num,b.email,b.dob,b.age,b.address);

}

            fn age(&self) ->u32 {
                self.age
            }
            fn gender(&self) ->&str {
                &self.gender
            }
            fn mobile_num(&self) ->i64 {
                self.mobile_num
            }
            fn email(&self) ->&str {
                &self.email
            }
            fn dob(&self) ->u32 {
                self.dob
            }
            fn address(&self) ->&str {
                &self.address
            }
            
        }
        fn main() {
            let b= Aadhar{
                name:String::from("Teja"),
                gender:String::from("Female"),
                mobile_num:9100631674,
                email:String::from("teju@gmail.com"),
                dob:10_09_1879,
                age:16,
                address:String::from("Mounika"),
            };
            println!("{:?},{:?},{:?},{:?},{:?},{:?},{:?}",b.name,b.gender,b.mobile_num,b.email,b.dob,b.age,b.address);
            
        }
        
        
        
        
           
        
        
            
        
            
            
        
        
            
        
            
        
        
        
}
fn email(&self) ->&str {
    &self.email
}
fn dob(&self) ->u32 {
    self.dob
}
fn address(&self) ->&str {
    &self.address
}

} fn main() { let b= Aadhar{ name:String::from("Teja"), gender:String::from("Female"), mobile_num:9100631674, email:String::from("teju@gmail.com"), dob:10_09_1879, age:16, address:String::from("Mounika"), }; println!("{:?},{:?},{:?},{:?},{:?},{:?},{:?}",b.name,b.gender,b.mobile_num,b.email,b.dob,b.age,b.address);

}

No runtime deps