Skip to content

Commit

Permalink
fix #21 missing lifetime support
Browse files Browse the repository at this point in the history
was fixed by migrating to macros 1.1
this only adds the testcase
  • Loading branch information
colin-kiegel committed Jan 14, 2017
1 parent 3394c8c commit d15d788
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

- migration to macros 1.1
### Added
- different setter pattern, e.g. `#[setters(immutable)]`
- private setters, e.g. `#[setters(private)]`
- additional debug info via env_logger, e.g. `RUST_LOG=derive_builder=trace cargo test`

### Changed
- migration to macros 1.1, please refer to the new docs

### Fixed
- missing lifetime support #21

## [0.2.1] - 2016-09-24

### Fixed
Expand Down
30 changes: 30 additions & 0 deletions derive-builder-test/tests/lifetime.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#[macro_use] extern crate derive_builder;

#[derive(Debug, PartialEq, Default, Builder, Clone)]
struct Lorem<'a> {
ipsum: &'a str,
}

impl<'a> Lorem<'a> {
pub fn new<T: Into<&'a str>>(value: T) -> Self {
Lorem {
ipsum: value.into()
}
}
}

#[test]
fn contructor_sanity_check() {
let x = Lorem::new("ipsum");

assert_eq!(x, Lorem { ipsum: "ipsum" });
}

#[test]
fn immutable_setter() {
let x = Lorem::new("")
.ipsum("ipsum")
.clone();

assert_eq!(x, Lorem { ipsum: "ipsum" });
}

0 comments on commit d15d788

Please sign in to comment.