« Back to home

Rust Number Conversion - Don't Follow the Book...


Bottom-Line Up Front: I think as should be harder to use for Integer conversion in Rust. I recommend you use TryFrom/TryInto instead. Here’s how I recommend doing it (more complete example of right/wrong at the end):

use std::convert::TryInto;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let orig: u64 = u64::MAX;

    let ti_u64: u64 = orig.try_into()?;
    let ti_i64: i64 = orig.try_into()?;
    let ti_u32: u32 = orig.try_into()?;

    Ok(())
}

I’m at an intermediate level with the Rust programming language. I’ve done a year of adventofcode, a medium-sized API server project, and little more. While refactoring some code in my project recently I got rid of some of my explicit string conversions and let the type inference system and From/Into do their jobs. Now that I’m more comfortable with reading code using From/Into patterns I think it’s actually simpler - I can easily understand and trust what the type inference system does in those instances. Before I had intuition about how the inference system worked, I didn’t trust it. I didn’t know what it was doing under the hood.

Read more »

Stories

During this leadership development course one of the instructors quoted one of his previous mentors saying that leaders should have stories ready about:

mission, discipline, loyalty, and safety

This is in line with what one of my former mentors told me more briefly, “you need stories”. Ok - I thought, but stories about what? I have stories… I can tell a story… Typically I’m coming up with something appropriate on the spot. There are pros and cons to that approach.

Read more »

Military Feedback

It will be a continuing struggle to stay on top of how the Air Force is changing in the feedback system, and the systems they add over the years.

https://www.af.mil/News/Article-Display/Article/2490030/air-force-announces-airmen-leadership-qualities/

Here’s a new one I need to stay on top of - a new additional feedback form. It looks fantastic - the “Airmen Leadership Qualities”.

During the Leadership Development Course communication section, the Chief said:

Great leaders help people understand their “now”, then help people understand the future

Read more »

Dear White Colonel

This is an interesting article shared as part of this leadership class I’m in right now: Dear White Colonel … we must address our blind spots around race

What I liked about this article is that by describing instances where the topic got steered wrong, and the author’s feedback about what got missed when that happened, the article provides a roadmap to steer conversations back in the right direction. I feel like these examples really resonate with me - as if I’ve been a part of conversations like this.

Read more »

Applying Personality Quiz Results

I’m finding this course pretty interesting.

They asked us to reflect on some of our results from a personality quiz - the one at 16personalities.com. I got an INFJ, but normally I’m INTJ and think I probably still am, really.

How will we apply what we know about our personalities to our interactions with our teams?

I’ll try to be more conscious about how I react to “perceiving” teammates. They may wait a while and not set a plan - that can be ok. It often feels wrong to me, though, in large part because it’s not how I’ve learned to work. As reflected by my personality.

Read more »

Managing Culture

This video discusses organizational culture - I don’t love it because it’s too cheesy-motivational to me.

https://youtu.be/neDFJlUCXR8

One think I do like about the video is that it provides some solid ways to change organizational culture. By providing a solid definition (even if it’s not the one I’d choose), the video is able to specify how to move the needle against that decision:

  1. clarify
  2. embody
  3. celebrate

Determine what behaviors will be rewarded or corrected in your organization, and clarify that to the entire team. Embody those behaviors and live up to them. As someone in my group said with the embody piece, “you get what you tolerate”, so correct or reward the right things. Find the right things to celebrate and do.

Read more »

Commander's Attention

I’m sitting in the Leader Development Course from Air University - distance learning. One of the stories I heard this morning has the crux - the commander needs to walk a line between being too involved and not being involved. The story involved the former commander trying to show he cared by being there when new members arrived, by sitting with folks as they did work, and by visiting them when they were out in the field. Later he learned that folks felt like he was checking up on them, making sure they were doing what they were supposed to.

Read more »

Google Fiber Broke My Sprinkler System

We got Google Fiber installed a couple weeks ago, shortly after it became available in the neighborhood. It has been great. There’s still some construction going on at the mouth of my neighborhood and it has caused one overnight outage… But that’s understandable.

What’s not understandable is why my sprinkler system stopped working at about the same time they installed the fiber…

Ok - so I can guess what happened. The fiber trench was run, then a few days later the sprinkler system was scheduled to run, but it did not. The trench for the fiber runs up to the house right next to where the sprinkler system control lines run into the ground. The trench crosses an area where the lines must run from the front into the backyard.

Read more »

Using AWS Lambda as Proxy

AWS Lambdas are some of the original “serverless computing” implementations. These little bits of code run when you hit an API endpoint, taking whatever inputs you provide and returning the output. They can be written in many programming languages, including my favorite: Python 3.

So I wondered - could I use this to build a simple little proxy at a URL? Why not, right? They can run any Python code… If I wanted to, I could use the result to evade perimeter firewalls that might be blocking many arbitrary destination hosts, but not AWS assets. It’s not uncommon for enterprises to block sites based on host or URL, but most still need users to be able to get work done. AWS is infrastructure that powers many other sites - so I suspect that most organizations have to let it get through.

Read more »

Creating a Roku Channel

I’ve been a Roku user for years. They were one of the original streaming boxes you could plug into your TV. Before I became one I debated over Mac Mini vs dedicated device… As a programmer - I love the ability to have complete (-ish) control over a device that’s outputting to a device so central to the home as a TV. As a person who pays an energy bill - I love something that sips less electricity in-general, like a more-dedicated device. Plus, the interface of the dedicated device is simpler than that for a Mac Mini.

Read more »