File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -745,13 +745,15 @@ variable.
745745
746746For example:
747747
748+ ```
748749let x: i32 = "I am not a number!";
749750// ~~~ ~~~~~~~~~~~~~~~~~~~~
750751// | |
751752// | initializing expression;
752753// | compiler infers type `&str`
753754// |
754755// type `i32` assigned to variable `x`
756+ ```
755757"## ,
756758
757759E0309 : r##"
@@ -760,6 +762,7 @@ how long the data stored within them is guaranteed to be live. This lifetime
760762must be as long as the data needs to be alive, and missing the constraint that
761763denotes this will cause this error.
762764
765+ ```
763766// This won't compile because T is not constrained, meaning the data
764767// stored in it is not guaranteed to last as long as the reference
765768struct Foo<'a, T> {
@@ -770,6 +773,7 @@ struct Foo<'a, T> {
770773struct Foo<'a, T: 'a> {
771774 foo: &'a T
772775}
776+ ```
773777"## ,
774778
775779E0310 : r##"
@@ -778,6 +782,7 @@ how long the data stored within them is guaranteed to be live. This lifetime
778782must be as long as the data needs to be alive, and missing the constraint that
779783denotes this will cause this error.
780784
785+ ```
781786// This won't compile because T is not constrained to the static lifetime
782787// the reference needs
783788struct Foo<T> {
@@ -788,6 +793,7 @@ struct Foo<T> {
788793struct Foo<T: 'static> {
789794 foo: &'static T
790795}
796+ ```
791797"##
792798
793799}
You can’t perform that action at this time.
0 commit comments