-
Notifications
You must be signed in to change notification settings - Fork 568
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fe189cd
commit 3e7b5dc
Showing
14 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// https://github.com/dtolnay/trybuild | ||
// trybuild is a crate that essentially runs cargo on the provided files, and checks the output. | ||
// Tests may suddenly fail after a new compiler release, and there's not much we can do about that. | ||
// If the test suite fails because of trybuild: | ||
// - Update your compiler to the latest stable version. | ||
// - If it still fails, update the stderr snapshots. To do so, run the test suite with | ||
// env variable TRYBUILD=overwrite, and submit the file changes in a PR. | ||
use trybuild::TestCases; | ||
|
||
#[test] | ||
fn ui() { | ||
let t = TestCases::new(); | ||
t.pass("tests/ui/simple-lens.rs"); | ||
t.pass("tests/ui/lens-attributes.rs"); | ||
t.compile_fail("tests/ui/with-empty-struct.rs"); | ||
t.compile_fail("tests/ui/with-tuple-struct.rs"); | ||
t.compile_fail("tests/ui/with-enum.rs"); | ||
t.compile_fail("tests/ui/with-union.rs"); | ||
|
||
t.compile_fail("tests/ui/with-snake_case.rs"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use druid::*; | ||
|
||
#[derive(Lens)] | ||
struct Item { | ||
#[lens(name = "count_lens")] | ||
count: usize, | ||
#[lens(ignore)] | ||
complete: bool, | ||
} | ||
|
||
impl Item { | ||
fn count(&self) -> usize { | ||
self.count | ||
} | ||
fn complete(&mut self) { | ||
self.complete = true; | ||
} | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
use druid::*; | ||
|
||
#[derive(Lens)] | ||
struct MyThing { | ||
field_1: i32, | ||
field_2: String, | ||
} | ||
|
||
fn main() { | ||
let _ = MyThing::field_1; | ||
let _ = MyThing::field_2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
use druid::*; | ||
|
||
#[derive(Lens)] | ||
struct Foobar; | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
error: Lens implementations can only be derived from structs with named fields | ||
--> $DIR/with-empty-struct.rs:4:1 | ||
| | ||
4 | struct Foobar; | ||
| ^^^^^^ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
use druid::*; | ||
|
||
#[derive(Lens)] | ||
enum Foobar { | ||
Foo(i32), | ||
Bar, | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
error: Lens implementations cannot be derived from enums | ||
--> $DIR/with-enum.rs:4:1 | ||
| | ||
4 | enum Foobar { | ||
| ^^^^ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#![allow(non_camel_case_types)] | ||
|
||
use druid::*; | ||
|
||
#[derive(Lens)] | ||
struct my_thing { | ||
field: i32 | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
error: Lens implementations can only be derived from CamelCase types | ||
--> $DIR/with-snake_case.rs:6:8 | ||
| | ||
6 | struct my_thing { | ||
| ^^^^^^^^ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
use druid::*; | ||
|
||
#[derive(Lens)] | ||
struct Foobar(i32, i64); | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
error: Lens implementations can only be derived from structs with named fields | ||
--> $DIR/with-tuple-struct.rs:4:1 | ||
| | ||
4 | struct Foobar(i32, i64); | ||
| ^^^^^^ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
use druid::*; | ||
|
||
#[derive(Lens)] | ||
union Foobar { | ||
foo: i32, | ||
bar: f64, | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
error: Lens implementations cannot be derived from unions | ||
--> $DIR/with-union.rs:4:1 | ||
| | ||
4 | union Foobar { | ||
| ^^^^^ |