結果

問題 No.9001 標準入出力の練習問題(テスト用)
ユーザー halshiphalship
提出日時 2016-09-26 18:24:18
言語 Rust
(1.77.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 981 bytes
コンパイル時間 12,537 ms
コンパイル使用メモリ 397,980 KB
最終ジャッジ日時 2024-04-27 02:23:16
合計ジャッジ時間 13,195 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
error: use of deprecated `try` macro
  --> src/main.rs:17:9
   |
17 |         try!(reader.read_line(&mut buf));
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: in the 2018 edition `try` is a reserved keyword, and the `try!()` macro is deprecated
help: you can use the `?` operator instead
   |
17 -         try!(reader.read_line(&mut buf));
17 +         reader.read_line(&mut buf)?;
   |
help: alternatively, you can still access the deprecated `try!()` macro using the "raw identifier" syntax
   |
17 |         r#try!(reader.read_line(&mut buf));
   |         ++

error: use of deprecated `try` macro
  --> src/main.rs:19:22
   |
19 |         let a: u32 = try!(list[0].parse());
   |                      ^^^^^^^^^^^^^^^^^^^^^
   |
   = note: in the 2018 edition `try` is a reserved keyword, and the `try!()` macro is deprecated
help: you can use the `?` operator instead
   |
19 -         let a: u32 = try!(list[0].parse());
19 +         let a: u32 = list[0].parse()?;
   |
help: alternatively, you can still access the deprecated `try!()` macro using the "raw identifier" syntax
   |
19 |         let a: u32 = r#try!(list[0].parse());
   |                      ++

error: use of deprecated `try` macro
  --> src/main.rs:20:22
   |
20 |         let b: u32 = try!(list[1].parse());
   |                      ^^^^^^^^^^^^^^^^^^^^^
   |
   = note: in the 2018 edition `try` is a reserved keyword, and the `try!()` macro is deprecated
help: you can use the `?` operator instead
   |
20 -         let b: u32 = try!(list[1].parse());
20 +         let b: u32 = list[1].parse()?;
   |
help: alternatively, you can still access the deprecated `try!()` macro using the "raw identifier" syntax
   |
20 |         let b: u32 = r#try!(list[1].parse());
   |                      ++

error: use of deprecated `try` macro
  --> src/main.rs:23:9
   |
23 |         try!(reader.read_line(&mut buf));
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: in the 2018 edition `try` is a reserved k

ソースコード

diff #

use std::io::{self, Read, BufRead, BufReader};
use std::error::Error;
use std::fmt;

#[derive(Debug)]
struct Content {
    a: u32,
    b: u32,
    s: String,
}

impl Content {
    fn from_reader<R: Read>(reader: R) -> Result<Content, Box<Error>> {
        let mut reader = BufReader::new(reader);

        let mut buf = String::new();
        try!(reader.read_line(&mut buf));
        let list: Vec<&str> = buf.trim().split(' ').collect();
        let a: u32 = try!(list[0].parse());
        let b: u32 = try!(list[1].parse());

        let mut buf = String::new();
        try!(reader.read_line(&mut buf));

        Ok(Content {
            a: a,
            b: b,
            s: buf.trim().to_string(),
        })
    }
}

impl fmt::Display for Content {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "{} {}", self.a + self.b, self.s)
    }
}

fn main() {
    let content = Content::from_reader(io::stdin()).unwrap();
    println!("{}", content);
}
0