]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/colorful-write-macros.rs
cleanup: s/impl Copy/#[derive(Copy)]/g
[rust.git] / src / test / run-pass / colorful-write-macros.rs
1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // no-pretty-expanded
12
13 #![allow(unused_must_use, dead_code, deprecated)]
14 use std::io::MemWriter;
15 use std::fmt;
16
17 struct Foo<'a> {
18     writer: &'a mut (Writer+'a),
19     other: &'a str,
20 }
21
22 struct Bar;
23
24 impl fmt::Writer for Bar {
25     fn write_str(&mut self, _: &str) -> fmt::Result {
26         Ok(())
27     }
28 }
29
30 fn borrowing_writer_from_struct_and_formatting_struct_field(foo: Foo) {
31     write!(foo.writer, "{}", foo.other);
32 }
33
34 fn main() {
35     let mut w = MemWriter::new();
36     write!(&mut w as &mut Writer, "");
37     write!(&mut w, ""); // should coerce
38     println!("ok");
39
40     let mut s = Bar;
41     {
42         use std::fmt::Writer;
43         write!(&mut s, "test");
44     }
45 }