rust-- 0.1.1

Turn Rust into C++
Documentation
#![allow(non_camel_case_types)]

use std::{
    fmt::Display,
    io::stdin,
    ops::{Shl, Shr},
    str::FromStr,
};

pub mod views;

/// ```
/// # use rust__::{cout, endl};
/// cout << "hello world" << endl;
/// ```
/// will output
/// ```text
/// hello world
/// ```

pub struct cout;

impl<T> Shl<T> for cout
where
    T: Display,
{
    type Output = Self;
    fn shl(self, rhs: T) -> Self::Output {
        print!("{rhs}");
        self
    }
}

pub struct endl;

impl Display for endl {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        writeln!(f)
    }
}

pub struct cin;

impl<T> Shr<&mut T> for cin
where
    T: FromStr,
{
    type Output = Result<(), T::Err>;

    fn shr(self, rhs: &mut T) -> Self::Output {
        let mut input = String::new();
        stdin().read_line(&mut input).unwrap();
        *rhs = input.trim().parse()?;
        Ok(())
    }
}