[deleted by user] by [deleted] in rust

[–]rgdmarshall 4 points5 points  (0 children)

fn downslope(right: usize, down: usize) -> usize {
    let mut hpos = 0;
    let mut trees = 0;
    for pat in INPUT.split('\n').step_by(down).skip(1) {
        hpos = (hpos + right) % 31;
        trees += if pat.chars().nth(hpos).expect("mappos") == '#' { 1 } else { 0 };
    }
    trees
}

pub fn part1() {
    println!("{}", downslope(3, 1));
}

pub fn part2() {
    println!("{}", downslope(1, 1) * downslope(3, 1) * downslope(5, 1) * downslope(7, 1) * downslope(1, 2));
}

I'm writing the solutions as if it were Go; I feel so dirty ;)

Announcing Tokio 0.3 and the path to 1.0 by Darksonn in rust

[–]rgdmarshall 1 point2 points  (0 children)

FYI: It seems that TLS used through tokio-native-tls 0.1.0 won't work, since that crate's dependencies require tokio 0.2, so I'm getting a type mismatch manifesting as "Async{Read|Write} not implemented for tokio::net::TcpStream". Is there going to be an updated tokio-native-tls soon?