File tree 1 file changed +6
-0
lines changed
1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -745,13 +745,15 @@ variable.
745
745
746
746
For example:
747
747
748
+ ```
748
749
let x: i32 = "I am not a number!";
749
750
// ~~~ ~~~~~~~~~~~~~~~~~~~~
750
751
// | |
751
752
// | initializing expression;
752
753
// | compiler infers type `&str`
753
754
// |
754
755
// type `i32` assigned to variable `x`
756
+ ```
755
757
"## ,
756
758
757
759
E0309 : r##"
@@ -760,6 +762,7 @@ how long the data stored within them is guaranteed to be live. This lifetime
760
762
must be as long as the data needs to be alive, and missing the constraint that
761
763
denotes this will cause this error.
762
764
765
+ ```
763
766
// This won't compile because T is not constrained, meaning the data
764
767
// stored in it is not guaranteed to last as long as the reference
765
768
struct Foo<'a, T> {
@@ -770,6 +773,7 @@ struct Foo<'a, T> {
770
773
struct Foo<'a, T: 'a> {
771
774
foo: &'a T
772
775
}
776
+ ```
773
777
"## ,
774
778
775
779
E0310 : r##"
@@ -778,6 +782,7 @@ how long the data stored within them is guaranteed to be live. This lifetime
778
782
must be as long as the data needs to be alive, and missing the constraint that
779
783
denotes this will cause this error.
780
784
785
+ ```
781
786
// This won't compile because T is not constrained to the static lifetime
782
787
// the reference needs
783
788
struct Foo<T> {
@@ -788,6 +793,7 @@ struct Foo<T> {
788
793
struct Foo<T: 'static> {
789
794
foo: &'static T
790
795
}
796
+ ```
791
797
"##
792
798
793
799
}
You can’t perform that action at this time.
0 commit comments