Rust generics

#[allow(warnings)]
fn main() {
    use demo::*;
    let v0 = mul(1, 2);
    let v2 = div(1.0, 2.);
    let v2 = add(1.0, 2.);
    let v2 = sub(1.0, 2.);
    let matrix1 = vec![vec![1.,2.,6.]]; 
    let matrix2 = vec![vec![2.,5.,6.]];
    let re = multiply_matrix(&matrix1, &matrix2);
    let pin = make_pin(vec![15,12]);
    let v = pin.to_vec();
}
#[allow(warnings)]
pub mod demo{
    use core::ops;
    use std::{pin::Pin, future::Future};
    pub fn mul<T: ops::Mul<Output = T>+ops::Add<Output = T>+ops::Div<Output = T>+ops::Sub<Output = T>+Copy>(a:T,b:T)->T{
        a*b+div(a, b)
    }
    pub fn div<T: ops::Mul<Output = T>+ops::Add<Output = T>+ops::Div<Output = T>+ops::Sub<Output = T>+Copy>(a:T,b:T)->T{
        a*b
    }
    pub fn add<T: ops::Mul<Output = T>+ops::Add<Output = T>+ops::Div<Output = T>+ops::Sub<Output = T>+Copy>(a:T,b:T)->T{
        a*b
    }
    pub fn sub<T: ops::Mul<Output = T>+ops::Add<Output = T>+ops::Div<Output = T>+ops::Sub<Output = T>+Copy>(a:T,b:T)->T{
        a*b
    }
    pub fn mul_add<T,U,C>(a:T,b:U,c:C)->T where T: ops::Mul<Output = T>+ops::Mul<U,Output = T> + ops::Add<C, Output = T>, U: ops::Mul<Output = T> + ops::Mul<T, Output = T>, C: ops::Add<Output = T> {
        (a*b)+c
    }
    //genaric T add i32 -> T
    pub fn generic_interact_with_integer<i32,T>(a:T,b:i32)->T where i32: ops::Add<T,Output = T>, T: ops::Add<Output = T> + Copy {
        b+a
    }
    //genaric T add i32 -> i32
    pub fn generic_interact_with_integer_1<i32,T>(a:T,b:i32)->i32 where i32: ops::Add<T,Output = i32>, T: ops::Add<Output = i32> + Copy {
        b+a
    }
    //genaric T add f64 -> T
    pub fn generic_interact_with_float<f64,T>(a:T,b:f64)->T where f64: ops::Add<T,Output = T>, T: ops::Add<Output = T> + Copy {
        b+a
    }
    //genaric T add f64 ->f64
    pub fn generic_interact_with_float_1<f64,T>(a:T,b:f64)->f64 where f64: ops::Add<T,Output = f64>, T: ops::Add<Output = f64> + Copy {
        b+a
    }
    pub fn generic_convert<T,U>(a:T)->U where T:std::convert::Into<U>,U:std::convert::From<T> {
        Into::into(a)
        // a.into()
    }
    pub fn generic_to_float1<f64,T>(a:T)->f64 where T:std::convert::Into<f64>,f64:std::convert::From<T> {
        a.into()
    }

    pub fn generic_to_float2<f64,T>(a:f64)->T where f64:std::convert::Into<T>,T:std::convert::From<f64> {
        a.into()
    }

    pub fn generic_partialord_bool<T:core::cmp::PartialOrd>(a:T,b: T)->bool{
        a>b
    }
    pub fn generic_partialord_bool1<T:core::cmp::PartialOrd<i32>>(a:T,b: i32)->bool{
        a>b
    }
    pub fn generic_partialord_bool2<T:core::cmp::PartialOrd<f32>>(a:T,b: f32)->bool{
        a>b
    }

    pub fn generic_partialeq_bool<T:core::cmp::PartialEq<f32>>(a:T,b: f32)->bool{
        a==b
    }
    pub fn generic_partialeq_bool1<T:core::cmp::PartialEq>(a:T,b: T)->bool{
        a==b
    }
    use std::fmt::Debug;
    use std::fmt::Display;
    pub fn genaric_iter<I>(a: I) where I: Iterator, I::Item: Debug+Display {
        for v in a{
            println!("{}",v);
        }
    }
    pub fn genaric_iter1<I>(a: I) where I: Iterator<Item=String>, I::Item: Debug+Display {
        for v in a{
            println!("{}",v);
        }
    }
    pub fn use_genaric_iter(){
        genaric_iter([1,2].into_iter());
        genaric_iter1(["0".to_string()].into_iter());
    }
    pub fn genaric_closure<T,U>(){
        let closure = |a:T,b:U|{};
    }

    
    pub fn new<T:Clone+Copy>(val:T,m: usize, n: usize) -> Vec<Vec<T>> {
        //returb 0 created n*m matrix
        let mut mat:Vec<Vec<T>> = Vec::new();
        for i in 0..m {
            mat.push(vec![val; n].to_vec());
        }
        let vec = mat.clone();
        vec
    }
    pub fn multiply_matrix<T:Clone+Copy+ops::Mul<Output = T>+ops::Add<Output = T>+ops::Div<Output = T>+ops::Sub<Output = T> + std::ops::AddAssign+std::convert::From<i32>>(
        matrix1: &Vec<Vec<T>>,
        matrix2: &Vec<Vec<T>>,
    ) -> Vec<Vec<T>> {
        let m = &matrix2.len();
        let n = &matrix1[0].len();
        pub fn generic_convert<T>(a:i32)->T where i32:std::convert::Into<T>,T:std::convert::From<i32>{
            Into::into(a)
        }
        let val = generic_convert::<T>(0);
        let mut matrix3: Vec<Vec<T>> = new(val,*&matrix2.len(), *&matrix2[0].len());
        for i in 0..*&matrix2.len() {
            for j in 0..*&matrix2[0].len() {
                for k in 0..*m {
                    matrix3[i][j] += matrix1[i][k] * matrix2[k][j];
                }
            }
        }
        matrix3
    }
    pub fn pow<T>(a: T, b: T) -> T
    where
        f64: From<T>,
        T: 'static
            + std::ops::MulAssign
            + std::fmt::Display
            + std::ops::Mul<Output = T>
            + Copy
            + std::convert::From<f64>,
    {
        let mut re = a;
        let aa: f64 = a.into();
        let bb: f64 = b.into();
        re = f64::powf(aa, bb).into();
        re
    }

    pub fn make_pin(list:Vec<u8>) -> Pin<Box<Vec<u8>>> {
        Box::pin(list)
    }
    
}