We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4e76ff8 commit ed7a30eCopy full SHA for ed7a30e
fromcomplex/Cargo.toml
@@ -0,0 +1,8 @@
1
+[package]
2
+name = "fromcomplex"
3
+version = "0.1.0"
4
+edition = "2021"
5
+
6
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7
8
+[dependencies]
fromcomplex/src/main.rs
@@ -0,0 +1,21 @@
+#[derive(Debug)]
+struct MyUnit;
+#[allow(dead_code)]
+enum MyOption<T> {
+ Some(T),
+ None,
9
+}
10
11
+impl From<()> for MyOption<MyUnit> {
12
+ fn from(_: ()) -> Self {
13
+ MyOption::Some(MyUnit)
14
+ }
15
16
17
+fn main() {
18
+ println!("{:?}", <MyOption<MyUnit>>::from(()));
19
+ let o: MyOption<MyUnit> = ().into();
20
+ println!("{:?}", o);
21
0 commit comments