For any prime number, p, where p is greater than or equal to 5, p²-1 is always divisible by 24.
This is a sobering, but essential read. The spreading ripples from this colossal error in judgment, are going to last for years, and they are going to alter the lives of everyone on the planet.
All governments suffer a recurring problem: Power attracts pathalogical
personalities. It is not that power corrupts but that it is magnetic to the
corruptible.
~ Frank Herbert
Seventy years ago, in January or February 1956, J.R.R. Tolkien wrote a letter to Michael Straight, editor of New Republic, in which he mentioned a “ferocious” letter he had received some time before. His correspondent had argued that Frodo, the protagonist of The Lord of the Rings, should have been executed as a traitor, not praised. “The ‘salvation’ of the world and Frodo’s own ‘salvation’," Tolkien replied, “is achieved by his previous pity and forgiveness of injury.”
Rust doesn’t provide namespaces, nor does it have static classes. If you want to group related functions under a named “thing”, without any actual data, a unit struct is the idiomatic way to accomplish this. Essentially the struct is being used as a logical container or namespace for the functions. The pattern is also known as a Unit Struct pattern, or a Zero-Sized Type (ZST) facade.
Here’s what it looks like:
pub struct Foo;
impl Foo {
pub fn bar() -> i32 { 43 }
pub fn baz() -> &'static str { "hello" }
}You could just have free functions in a module, but the unit struct pattern has some specific advantages:
Trait implementation: You can implement traits on a unit struct. This is the
primary reason for using this pattern. For example, you could implement a
Handler, Strategy, or Factory trait on Foo. Something you can’t do on
loose functions.
It can be passed as a value: Foo is a concrete type, so you can pass it to
functions that expect a generic T bounded by some trait. Or you can use it
in a collection.
It signals intent: Grouping methods on a struct signals that they are conceptually related in a way that’s more explicit than just a module.
The zero-sized part matters. Because Foo holds no data, it costs
nothing at runtime. std::mem::size_of::<Foo>() is 0. The compiler may
eliminate any instance of it, so it’s a pure compile-time organizational tool
with no overhead.
A real world example using the marker/strategy pattern
pub struct JsonSerializer;
pub struct XmlSerializer;
trait Serializer {
fn serialize(data: &str) -> String;
}
impl Serializer for JsonSerializer {
fn serialize(data: &str) -> String { format!("{{\"data\": \"{}\"}}", data) }
}
impl Serializer for XmlSerializer {
fn serialize(data: &str) -> String { format!("<data>{}</data>", data) }
}Now you can write generic code over T: Serializer and swap implementations at
compile time with zero runtime costs.
To summarize: a unit struct, also called a ZST namespace/facade pattern, is used for trait implementation, type-level polymorphism, and logical grouping. All with zero runtime cost.
30 March 1973
Dear Mr. Nadeau:
As long as there is one upright man, as long as there is one compassionate
woman, the contagion may spread and the scene is not desolate. Hope is the
thing that is left to us, in a bad time. I shall get up on Sunday morning and
wind the clock, as a contribution to order and steadfastness.
Sailors have an expression about the weather: they say, the weather is a greate
bluffer. I guess the same is true of our human society-things can look dark,
then a break shows in the clouds, and all is changed, sometimes rather
suddenly. It is quite obvious that the human race has made a queer mess of life
on this planet. But as a people we probably harbor seeds of goodness that have
lain for a long time waiting to sprout when the conditions are right. Man’s
curiosity, his relentlessness, his inventiveness, his ingenuity have led him
into deep trouble. We can only hope that these same traits will enable him to
claw his way out.
Hang on to your hat. Hang on to your hope. And wind the clock, for tomorrow is
another day.
Sincerely,
E. B. White
In a little over 2 months I’ll be turning 65. Setting aside any existential issues, there are some decisions and paperwork involved.
You need to enroll in Medicare, even if you aren’t going to start using it when you turn 65. The enrollment period is three months on either side of your birth month. I was born in May, so the seven month span is February-March-April, then May, followed by June-July-August.
This enrollment happens through the government Medicare site.
I received a letter from my employer about making a health insurance choice. I can keep my employment sponsored health insurance (for as long as I am employed), but I have to make that designation. What I’m really doing is saying that my work insurance will be the primary coverage, and Medicare will be the secondary coverage.
Medicare comes in multiple pieces. Part A, Part B, and Part D. Not to mention supplemental Medicare insurance. Part A is hospital, skilled nursing, and hospice. Part B is outpatient care and doctor visits. Part D is prescription drug coverage. While A is likely premium fee, Parts B and D will have a monthly premium.
Since my employer has more than 20 employees, I can delay signing up for Parts B and D, until my primary coverage goes away. I must enroll in Part A, which is usually premium free for most people.
This life event has triggered a flood of Medicare related postal mail. And, so far, two cold calls visits to our house. My turning 65 represents potential fees and income for insurance providers, so they come, unasked, to the house and want to talk to me.
I’ll enroll in Part A. And I’ll notify my employer that I am keeping my BC/BS insurance as primary. I plan on using the two years before I pull the retirement ripcord to research and understand how all the Medicare parts work, and where supplemental insurance might be necessary. And I’ll pick someone to work with to set everything up. Probably not someone who shows up at the front door unasked for.
And I may make a sign for the door that says unasked for Medicare advise in the guise of well meaning insurance salespeople will be met with a polite, but firm, “No thank you” followed by my closing the door.
I’m particularly partial to numbers 3 and 4. When in doubt, use brute force.
The fine folks at CERN are science-ing the shit out of this.
Montana is going in the opposite direction as states like California and Virginia. They are protecting citizens not corporations. Good on them.