These are chat archives for rust-lang/rust

2nd
Dec 2018
laurent bernabé
@loloof64
Dec 02 2018 00:38 UTC
Hi everyone ! Given :
#[derive(Clone)]
pub struct ChessBoard
{
    drawing_area: DrawingArea,
    reversed: bool,
    logic: RefCell<ChessGame>,
    cells_size: u32,
    moved_piece: RefCell<Option<MovedPiece>>,
    pieces_images: HashMap<char, Pixbuf>,
}

#[derive(Clone, Debug)]
struct MovedPiece
{
    piece_type: Piece,
    coords_x: f64,
    coords_y: f64,
    start_file: u8,
    start_rank: u8
}
and the following method of struct ChessBoard
fn handle_mouse_moved(&self, coords: (f64, f64)) {
        match self.moved_piece.into_inner() {
            Some(ref mut moved_piece) => moved_piece.translate_to(coords.0, coords.1),
            None => {}
        }
    }
How can solve the error cannot move of borrowed content because of the line match self.moved_piece.into_inner() ?
Denis Lisov
@tanriol
Dec 02 2018 00:41 UTC
self.moved_piece.borrow_mut().take() if you want to take it out
laurent bernabé
@loloof64
Dec 02 2018 00:42 UTC
Thanks : going to try right now :smile:
Denis Lisov
@tanriol
Dec 02 2018 00:42 UTC
Or something like *self.moved_piece.borrow_mut() if you keep it there
laurent bernabé
@loloof64
Dec 02 2018 00:42 UTC
Yes, it compiles : thank you very much :smile:
Denis Lisov
@tanriol
Dec 02 2018 00:43 UTC
Actually, in a mouse move handler you probably want the latter :-)
laurent bernabé
@loloof64
Dec 02 2018 00:43 UTC
Right, indeed, I take the latter form
Jayesh Badwaik
@jayeshbadwaik
Dec 02 2018 00:47 UTC
Hello, is there a way to configure the textwidth for rustfmt?
more importantly, where can I find the documentation for various options in rustfmt.toml
Denis Lisov
@tanriol
Dec 02 2018 00:50 UTC
You can find them in the repo, but, AFAIK, it's considered more idiomatic to use the default style.
Jayesh Badwaik
@jayeshbadwaik
Dec 02 2018 00:52 UTC
Yeah, I am using the default style, but the 100 character width is difficult to read for me, so that's the only thing I am changing to 80
Thanks.
nutspanther
@nutspanther
Dec 02 2018 16:00 UTC
quick question: I have a CLI app that runs a read_line() for users to update a bearer token. In OSX terminal, if they copy/paste the token the terminal won't accept the whole token, but it works in my built-in console when debugging the app. Any suggestions on how to handle this for my users that run directly from terminal?
André E. Veltstra
@aev-mambro2
Dec 02 2018 20:17 UTC
@nutspanther Are there settings in an OSX terminal to configure the amount of copied/pasted characters? Windows command terminals let us set the size and amount of output buffers.
Tim Robinson
@1tgr
Dec 02 2018 21:24 UTC
I’m not aware of anything in OS X or in Rust that would break this
Without knowing more about what does work, and what are these tokens being pasted
nutspanther
@nutspanther
Dec 02 2018 22:08 UTC
@aev-mambro2 I wasn't able to find a size customization. The string is a bearer token that has around 1350 characters
It's odd, because I set the token as an argument when they run the app and it works fine, but when the token expires I ask for a new one for retrying the failed request and all subsequent requests. This is where it is failing