I’ve just solved a problem at Leetcode with following signature:
pub fn num_islands(grid: Vec<Vec<char>>) -> i32
When I solved it I changed it to:
pub fn num_islands(mut grid: Vec<Vec<char>>) -> i32 {
I got some free time, therefore, more Rust!
I’m reading chapter where ‘move’ is described. This chapter discloses one more important detail: how strings are stored. Rust uses ‘pascal style’ strings. That means they have…
Brief introduction: I’m trying to create a good way to work with an image, defined by two sets of coordinates: pixel-level (integers), and Cartesian (floating points, with dx, dy for the size of a pixel in those Cartesian coordinates). Meanwhile the actual…
dx
dy
It was a long and busy delay, but I’m back.
I’d tried to cheat on my learning process… More specific, I’d tried to change the way I read tutorial. I simply read few chapters just before going to bed, it was easy to do.
Yeah, Rust is brutal when you have lists.
The problem: you get a list, return second half of it. I decided to solve it without using Clone.
Clone
Let’s talk about two dimensional matrices in Rust. To be precise, two-dimensional matrices written as nested arrays.
A simple 2x2 matrix is looks like this:
let matrix = [[1, 2], [3, 4]];
I’d like to spend some time studying closures. It’s a tricky topic. Before everything else, I’d like to admire their syntax: It’s way more elegant then python’s keyword-based lambda ugliness. Just compare:map(|x| x > 0, somelist) and map(lambda x: x > 0, somelist).
lambda
map(|x| x > 0, somelist)
map(lambda x: x > 0, somelist)
I was busy for the last few weeks. I like to learn fun and geeky stuff, but my job occasionally requires me to learn very new technologies with bad documentation or without it at…