Skip to content

Commit 89a16e9

Browse files
committed
---
yaml --- r: 39932 b: refs/heads/dist-snap c: 06a17a7 h: refs/heads/master v: v3
1 parent 2c0b678 commit 89a16e9

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: a810c03263670238bccd64cabb12a23a46e3a278
99
refs/heads/incoming: e90142e536c150df0d9b4b2f11352152177509b5
10-
refs/heads/dist-snap: d81196ce96b1d3da7bb718ed4c5e9d4810be896e
10+
refs/heads/dist-snap: 06a17a7ce5c2e6ff71fd6d24706dce15f51b8580
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1313
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/doc/rust.md

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,7 +1178,7 @@ trait shape {
11781178

11791179
This defines a trait with two methods.
11801180
All values that have [implementations](#implementations) of this trait in scope can have their `draw` and `bounding_box` methods called,
1181-
using `value.bounding_box()` [syntax](#field-expressions).
1181+
using `value.bounding_box()` [syntax](#method-call-expressions).
11821182

11831183
Type parameters can be specified for a trait to make it generic.
11841184
These appear after the name, using the same syntax used in [generic
@@ -1558,13 +1558,27 @@ let base = {x: 1, y: 2, z: 3};
15581558
{y: 0, z: 10, .. base};
15591559
~~~~
15601560

1561+
### Method-call expressions
1562+
1563+
~~~~~~~~{.ebnf .gram}
1564+
method_call_expr : expr '.' ident paren_expr_list ;
1565+
~~~~~~~~
1566+
1567+
A _method call_ consists of an expression followed by a single dot, an identifier, and a parenthesized expression-list.
1568+
Method calls are resolved to methods on specific traits,
1569+
either statically dispatching to a method if the exact `self`-type of the left-hand-side is known,
1570+
or dynamically dispatching if the left-hand-side expression is an indirect [trait type](#trait-types).
1571+
1572+
15611573
### Field expressions
15621574

15631575
~~~~~~~~{.ebnf .gram}
1564-
field_expr : expr '.' expr
1576+
field_expr : expr '.' ident
15651577
~~~~~~~~
15661578

1567-
A dot can be used to access a field in a record.
1579+
A _field expression_ consists of an expression followed by a single dot and an identifier,
1580+
when not immediately followed by a parenthesized expression-list (the latter is a [method call expression](#method-call-expressions)).
1581+
A field expression denotes a field of a [structure](#structure-types) or [record](#record-types).
15681582

15691583
~~~~~~~~ {.field}
15701584
myrecord.myfield;
@@ -1574,17 +1588,9 @@ myrecord.myfield;
15741588
A field access on a record is an [lvalue](#lvalues-rvalues-and-temporaries) referring to the value of that field.
15751589
When the field is mutable, it can be [assigned](#assignment-expressions) to.
15761590

1577-
When the type of the expression to the left of the dot is a boxed
1578-
record, it is automatically derferenced to make the field access
1579-
possible.
1580-
1581-
Field access syntax is overloaded for [trait method](#traits)
1582-
access. When no matching field is found, or the expression to the left
1583-
of the dot is not a (boxed) record, an
1584-
[implementation](#implementations) that matches this type and the
1585-
given method name is looked up instead, and the result of the
1586-
expression is this method, with its _self_ argument bound to the
1587-
expression on the left of the dot.
1591+
When the type of the expression to the left of the dot is a pointer to a record or structure,
1592+
it is automatically derferenced to make the field access possible.
1593+
15881594

15891595
### Vector expressions
15901596

0 commit comments

Comments
 (0)