File: impl_mut.rs

package info (click to toggle)
rust-shrinkwraprs 0.3.0-3
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 164 kB
  • sloc: makefile: 4
file content (58 lines) | stat: -rw-r--r-- 1,096 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#![allow(unused_variables, dead_code)]

#[macro_use] extern crate shrinkwraprs;
extern crate core;

#[derive(Shrinkwrap)]
#[shrinkwrap(mutable)]
struct Email(String);

#[derive(Shrinkwrap)]
#[shrinkwrap(mutable)]
struct CodeSpan(u64, u64, #[shrinkwrap(main_field)] String);

#[derive(Shrinkwrap)]
#[shrinkwrap(mutable)]
struct PhoneNumber {
  number: String
}

#[derive(Shrinkwrap)]
#[shrinkwrap(mutable)]
struct FileContents {
  #[shrinkwrap(main_field)] contents: String,
  linked_inodes: u64
}

#[test]
fn test_tuple_can_deref_mut() {
  let mut email = Email("chiya+snacks@natsumeya.jp".into());

  email.push_str(".co");
}

#[test]
fn test_nary_tuple_can_deref_mut() {
  let mut span = CodeSpan(0, 24, "  impl  ".into());

  span.push_str("!Sync for MyCell");
}

#[test]
fn test_single_can_deref_mut() {
  let mut number = PhoneNumber {
    number: "+1 (800) 273-8255".into()
  };

  number.push_str(" (20)");
}

#[test]
fn test_multi_can_deref_mut() {
  let mut contents = FileContents {
    contents: "fjkfdlsjfkdlsjflks".into(),
    linked_inodes: 3
  };

  contents.push_str("fdjskl");
}