These are chat archives for rust-lang/rust

31st
Oct 2017
Fra ns
@snarf95_twitter
Oct 31 2017 12:08 UTC
anyone interested in doing a review of my very simple / not competetive try at a chess game using rust? Anyhow here's a link to the repo: https://github.com/McGittyHub/chess-rs
ps. I'm a rust-newbie
Jonas Platte
@jplatte
Oct 31 2017 12:33 UTC
@snarf95_twitter First thing I noticed is that you have a &self method on a Copy type (Player::opposite). I don't know if there is an actual convention about this, but I would intuitively use self for this.
Hm, why is this unreachable!() instead of return None?
Jérôme Tamba
@superseed
Oct 31 2017 13:26 UTC
Maybe Board::new_from_setup could be an impl of the From trait for the [[PP::None; 8]; 8] type ?
@snarf95_twitter and considering Board::print_board's purpose is to be println!ed, you could go with implementing Display instead
Fra ns
@snarf95_twitter
Oct 31 2017 13:30 UTC
@jplatte thanks all your points makes sense, I’ll look into fixing it
Implementing display would be a good idea, yes. But PP is more like an intern backend struct don’t really want to expose it
Jérôme Tamba
@superseed
Oct 31 2017 13:33 UTC
Oh okay
Looks like a pretty harmless struct though, basically a boosted Option
Actually looking at it again, PP could be struct made of a PieceType and a Player ?
Denis Lisov
@tanriol
Oct 31 2017 13:36 UTC
Maybe just a tuple (Player, PieceType)?
Jérôme Tamba
@superseed
Oct 31 2017 13:36 UTC
I mean, an enum containing either (PieceType, Player) or None
Or an option of Denis' idea yeah
Denis Lisov
@tanriol
Oct 31 2017 13:37 UTC
Maybe an Option<(Player, PieceType)>
Fra ns
@snarf95_twitter
Oct 31 2017 13:38 UTC
Hmm yea
Denis Lisov
@tanriol
Oct 31 2017 13:41 UTC
Do you intentionally duplicate information about piece positions both in black_pieces/white_pieces and in map?
Fra ns
@snarf95_twitter
Oct 31 2017 13:42 UTC
Only because I have an idea that it’ll improve cache locality
Haven’t tried to change it
Jérôme Tamba
@superseed
Oct 31 2017 13:43 UTC
btw if you keep PP as struct or enum, you can implement display for it too, and that can replace to_display_char
And None can be printed as a whitespace I guess, so print_board becomes simpler by dropping the if let
Fra ns
@snarf95_twitter
Oct 31 2017 13:46 UTC
@superseed yes thats true
Moggers
@Moggers
Oct 31 2017 15:13 UTC
is there a gitter server for RLS?
Hans W. Uhlig
@huhlig
Oct 31 2017 15:13 UTC
I think it's just here
Aleksey Kladov
@matklad
Oct 31 2017 15:14 UTC
I think RLS team uses dev-tools IRC
Moggers
@Moggers
Oct 31 2017 15:15 UTC
all I can find is the impl-period gitter
Moggers
@Moggers
Oct 31 2017 15:15 UTC
which sounds like its for contributors
oh, irc, gotcha