We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a576362 commit e2caab1Copy full SHA for e2caab1
library/std/src/keyword_docs.rs
@@ -1195,6 +1195,28 @@ mod ref_keyword {}
1195
/// Ok(())
1196
/// }
1197
/// ```
1198
+///
1199
+/// Within [closures] and [`async`] blocks, `return` returns a value from within the closure or
1200
+/// `async` block, not from the parent function:
1201
1202
+/// ```rust
1203
+/// fn foo() -> i32 {
1204
+/// let closure = || {
1205
+/// return 5;
1206
+/// };
1207
1208
+/// let future = async {
1209
+/// return 10;
1210
1211
1212
+/// return 15;
1213
+/// }
1214
1215
+/// assert_eq!(foo(), 15);
1216
+/// ```
1217
1218
+/// [closures]: ../book/ch13-01-closures.html
1219
+/// [`async`]: ../std/keyword.async.html
1220
mod return_keyword {}
1221
1222
#[doc(keyword = "self")]
0 commit comments