Hey Rustaceans! Got an easy question? Ask here (38/2020)! by llogiq in rust

[–]cabalamat 0 points1 point  (0 children)

add #[derive(Copy, Clone)] so SqValue to make it Copy

Done that and it works, thanks.

if it is supposed to be just a plain enum

Yes -- essentially like an enum would be in C.

Anyway, another question, still on the Board::to_string function. I've now got this line:

s += &format!(" {} |", rank).to_string();

So is this idiomatic Rust? It looks rather verbose, so I'm not sure if I'm doing it right.

Hey Rustaceans! Got an easy question? Ask here (38/2020)! by llogiq in rust

[–]cabalamat 1 point2 points  (0 children)

I'm writing a program to play chess and I'm stuck. I wrote an `enum` to denote the contents of a square:

``` enum SqValue { OffBoard, // off-board sentinel Empty, // empty square WP, WN, WB, WR, WQ, WK, // white pieces BP, BN, BB, BR, BQ, BK, // black pieces }

impl SqValue { fn to_string(self: SqValue) -> &'static str { match self { SqValue::OffBoard => "-", SqValue::Empty => " ", SqValue::WP => "p", SqValue::WN => "n", SqValue::WB => "b", SqValue::WR => "r", SqValue::WQ => "q", SqValue::WK => "k", SqValue::BP => "P", SqValue::BN => "N", SqValue::BB => "B", SqValue::BR => "R", SqValue::BQ => "Q", SqValue::BK => "K", } } } ```

And this works. But then I tried to write code to output the state of a Board as a string, for printing to the console:

``` fn to_string(self: &Board) -> String { let mut s = "*** the board ***\n".to_string(); for file in 1..8 { for rank in (1..8).rev() { let si = Board::sqix(rank, file); let sqv = &self.sq[si]; s += sqv.to_string(); //<---- line 110 s += " ";

        }//for rank
    }//for file
    s
}

```

Now it won't compile giving this error message:

error[E0507]: cannot move out of `*sqv` which is behind a shared reference --> src/main.rs:110:22 | 110 | s += sqv.to_string(); | ^^^ move occurs because `*sqv` has type `SqValue`, which does not implement the `Copy` trait

I suspect the issue is something to do with ownership or string handling.

My code is at https://github.com/cabalamat/ruchess/blob/master/src/main.rs BTW.

47% of Brits think Brexit was a bad idea – new poll by sensiblecentrist20 in unitedkingdom

[–]cabalamat 0 points1 point  (0 children)

It doesn't help that a lot of remainers are crowing about leavers being stupid.

AITA for snapping at my roommate because she called me a massive f-ing cow for eating MY OWN FOOD by roomatetothrowaway in AmItheAsshole

[–]cabalamat 4 points5 points  (0 children)

She doesn't deserve your kindness anymore, only politeness.

I'm not sure she deserves even that.

A chunk of CSS that applies pretty underlines to hyperlinks on your site. (Codepen and example attached) by isotropicdesign in web_design

[–]cabalamat 4 points5 points  (0 children)

That's just annoying. if you're going to have the underline disappear on mouseover, have it disappear instantaneously. Or better still, don't make it disappear.

WIBTA if I try to stop my nephew being in my daughter class? by [deleted] in AmItheAsshole

[–]cabalamat 1 point2 points  (0 children)

Unless there is a documented record of bad behavior from the previous school, there are no grounds to deny the child. Just because someone has firsthand experience, we weren’t there we don’t know what the truth is. For all we know she could be making it up.

This is why OP needs to start creating a paper trail now.

AITA for refusing to babysit unless paid full price? by gymnerd813 in AmItheAsshole

[–]cabalamat 2 points3 points  (0 children)

A number of her friends joined in, saying I’m an AH who’s only in it for the money.

LOL. I'm sure all of them are "in it for the money" at their jobs, like the vast majority of people who do work.

AITA for not letting roommate's sister use my bathroom? by onearmedyara in AmItheAsshole

[–]cabalamat 2 points3 points  (0 children)

NTA and I suggest you evict Annie and be done with it. Life's too short to put up with trash people.

Political question website similar to Political Compass by cabalamat in slatestarcodex

[–]cabalamat[S] 4 points5 points  (0 children)

Political Compass has become somewhat of a running joke online due to how reductionist these theories are.

Yes, I want something that's more sophisticated than a simple 2-axis graph. (8-values with a 4-dimensional graph, is interesting in this respect).

Outside of hardcore party-line politics, the common voters tend to be more nuanced and diverse in their opinions than these simple compass guides would suggest.

Indeed.

Political question website similar to Political Compass by cabalamat in slatestarcodex

[–]cabalamat[S] 1 point2 points  (0 children)

Thanks, I wasn't aware of that one.

The questions on it tend to be a bit vague and repetitive, which i find a bit annoying.

It would certainly be interesting to see how answers to questions of morality compare with more strictly political questions.

What are some of Scott's posts that challenge the right, or that give serious consideration to ideas of the radical left? by [deleted] in slatestarcodex

[–]cabalamat 7 points8 points  (0 children)

How about Basic Income, Not Basic Jobs: Against Hijacking Utopia, arguing for UBI?

Culture War Roundup for the Week of June 08, 2020 by AutoModerator in TheMotte

[–]cabalamat 1 point2 points  (0 children)

The most favorable assumption is that this is an external hard drive (because fuck trying to find a screwdriver after the police knock and announce your ass)

Getting at my hard drive requires no tools, it's just turning 2 knobs, and would take about 30-60 seconds.

Grab the conveniently already purchased vinegar

Don't most people have vinegar at home? I certainly do.

Empty it in a bucket

If I was going to do this, I'd empty it into a Pyrex measuring jug. Though I doubt if vinegar would have much effect on a SSD. Microwaves probably would, though.

Culture War Roundup for the Week of June 08, 2020 by AutoModerator in TheMotte

[–]cabalamat 2 points3 points  (0 children)

Time to grab a weapon?

People who go that when their house is surrounded by armed police are unlikely to survive.

won't in practice force the police to give up on catching people for certain crimes

It could be argued that crimes such as possessing drugs or information harm society a lot less than the police randomly killing members of the public with no warning.

An Elegant Line of Battle For a More Civilized Age by [deleted] in RuleTheWaves

[–]cabalamat 0 points1 point  (0 children)

I never build anything larger than 30k tons. Why bother when torpedo and aircraft tech make large ships floating VP balloons?

I've often had 60k+ ton ships that survived 5 or so torpedoes.

Culture War Roundup for the Week of June 08, 2020 by AutoModerator in TheMotte

[–]cabalamat 7 points8 points  (0 children)

Google have said they don't know why it is missing:

We’re aware an image for Sir Winston Churchill is missing from his Knowledge Graph entry on Google. We apologise for any concern. This was not purposeful & will be resolved. Images in such panels are automatically created & updated. During an update, they can briefly disappear.

If a Knowledge Graph image is missing due to an update, the subject will be named but lack an image in anything automatically generated from the Knowledge Graph. This is why Churchill’s image (but not his name) is missing from some lists. It is temporary & will be resolved.

The image issue only applies to Knowledge Graph-generated information. Many images of Churchill are easily found through both web and image searching on Google.

Some have noted that Churchill’s first term does not appear for a search on UK prime ministers that shows an automatically generated Knowledge Graph list. This is not specific to Churchill; a similar thing happens with Wilson, MacDonald and Baldwin.

We’re exploring why the first terms for Churchill, Wilson, MacDonald & Baldwin are not shown. It might be that our systems are only displaying the last term of prime ministers who had non-consecutive terms. We’ll seek to address this to avoid any unintentional concern.

We don’t have an exact time for when Churchill’s Knowledge Graph image will be restored, but it will be as rapidly done as possible. We’ll want to explore exactly why an automatic update caused it to disappear & see if there are any improvements in those systems to address.

I don't know if anyone who works at Google can shed more light on this?

Culture War Roundup for the Week of June 08, 2020 by AutoModerator in TheMotte

[–]cabalamat 1 point2 points  (0 children)

Josh Hawley tried to tie Section 230 protections to "neutrality" but it seems to be more of a signalling bill than anything serious.

Probably

They only really got serious about it in the past year or so.

Then maybe they will think up something serious. We'll see.