George Shuklin

I found a problem with chars iterator for Sting. next() function returns Option<char> (owned chars), and adding .peekable() to iterator gives .peek() function which returns Option<&char>. Which is a great inconvenience if you try to work with those two types without unwrapping them. You can’t compare next-returned value with peek-returned value directly.

I asked on SO and got few answers, the best of which was: Option has copied method.

It does copy for reference inside Option :

Option<&T>.cloned() -> Option<T>

Which allows conveniently make peek to behave like ‘next’:

let value = iterator.next();
let next_value = iterator.peek().copied();
if value == next_value {
...
}

--

--

I’ve just committed the silliest blunder possible. I wrote a timer with * in a seconds field for OnCalendar.

This is what I wrote:

OnCalendar=*-*-* *:0,15,30,45:*

What I’ve meant? I wanted it to run every 15 minutes.

What thing I wrote means?

Uh… Every 15 minutes run job every second for that minute. Buhhaaaah. 60*4 = 240 jobs per hour. Given that job is run for about 5 minutes, that’s infinite job queue.

Why I hadn’t noticed it right away? Because after daemon-reload it’d shown me in “LEFT” column a decent “3min 8s left” or something like that. Which looked exactly like a job with 15-minutes interval.

How proper schedule looks like?

OnCalendar=*-*-* *:0,15,30,45:00

Yes. Every 15 minutes when seconds are zero. Not ‘any second’.

Huh. I’m happy I caught it in pre-production setup.

--

--

George Shuklin

George Shuklin

I work at Servers.com, most of my stories are about Ansible, Ceph, Python, Openstack and Linux. My hobby is Rust.