From d15d788e46038e883f28708d844245a03e14a483 Mon Sep 17 00:00:00 2001 From: Colin Kiegel Date: Sat, 14 Jan 2017 23:46:16 +0100 Subject: [PATCH] fix #21 missing lifetime support was fixed by migrating to macros 1.1 this only adds the testcase --- CHANGELOG.md | 9 ++++++-- derive-builder-test/tests/lifetime.rs | 30 +++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 derive-builder-test/tests/lifetime.rs diff --git a/CHANGELOG.md b/CHANGELOG.md index 683107eb..a57537f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/derive-builder-test/tests/lifetime.rs b/derive-builder-test/tests/lifetime.rs new file mode 100644 index 00000000..3a8b7319 --- /dev/null +++ b/derive-builder-test/tests/lifetime.rs @@ -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>(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" }); +}