index
method and [idx]
sugar works differently in async
blocks/functionsimpl Foo { fn bar(&self) { } }
fn foo() {
let x = ...;
let y = ...;
let z = foo().bar();
// desugared
let z = { let f = foo(); Foo::bar(&f) };
yield;
}
{ let p = &X; ... await; }
where X
is not Send
)foo(bar, x.await, baz)
, (bar, x.await, baz)
bar().as_ref()
or &bar()
match client.status()
introduces an auto-ref on client
but since this is a place expression ("lvalue") no temporary is created and the value is ultimately not live across the await
(if this had been Client::new().status()
the story would be different)peach[0]
in let r = &peach[0]
winds up having an extended temporary lifetime until the end of the block, but in fact no temporary will be createdExample where treating just as temporaries would be wrong:
foo(X, bar.await, Y)
let foo = (X, bar.await, Y);
Example ergonomic win that would derive from treating variables with more precision:
let x = mutex.lock();
*x += 1;
drop(x);
foo.await
let x = &Client::new();
// let x = Client::new();
// let x = &x;
let x = (&Client::new(), &Client::new());
let x = Foo { f: &Client::new() };
let x = Client::new().as_ref(); // RFC #66 would fix this =)
fn foo() -> SomeStruct { }
match foo().bar {
x => { }
} // <-- remainder of `foo()` is freed here
or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Do you want to remove this version name and description?
Syncing