File: transformers.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 (24 lines) | stat: -rw-r--r-- 523 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
#![allow(unused_variables)]

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

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

#[test]
fn test_map_mut() {
  let mut email = Email("aoi.miyamori@musashino".into());
  let orig_len = email.len();

  email
    .transform(|s| s.push_str(".co"))
    .transform(|s| s.push_str(".jp"));

  let new_len = email.len();
  let siphoned_len = email.siphon(|s| s.len());

  assert_eq!(new_len, orig_len + 6);
  assert_eq!(new_len, siphoned_len);
}