Skip to content

Commit 6a1c9b4

Browse files
Add more links to our OSS rustdoc from our generated code guide.
PiperOrigin-RevId: 864448698
1 parent 8c16090 commit 6a1c9b4

File tree

1 file changed

+24
-13
lines changed

1 file changed

+24
-13
lines changed

content/reference/rust/rust-generated.md

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ Most users should import our prelude, which only includes traits and our
8787
rather avoid preludes, you can always import the specific traits as needed (see
8888
the
8989
<!-- TODO: replace `4.32.0-prerelease` with `latest` once we do a stable release -->
90-
[documentation here](https://docs.rs/protobuf/4.32.0-release/protobuf/trait.Message.html)
90+
[documentation here](https://docs.rs/protobuf/4.33.5-release/protobuf/trait.Message.html)
9191
for the names and definitions of the traits if you want to import them
9292
directly).
9393

@@ -244,9 +244,10 @@ The compiler generates the following accessor methods:
244244
* `fn has_foo(&self) -> bool`: Returns `true` if the field is set.
245245
* `fn foo(&self) -> i32`: Returns the current value of the field. If the field
246246
is not set, it returns the default value.
247-
* `fn foo_opt(&self) -> protobuf::Optional<i32>`: Returns an optional with the
248-
variant `Set(value)` if the field is set or `Unset(default value)` if it's
249-
unset.
247+
* fn foo_opt(&self) -> protobuf::Optional<i32>`: Returns an optional with the
248+
variant`Set(value)`if the field is set or`Unset(default value)`if it's
249+
unset. See [`Optional`
250+
rustdoc](https://docs.rs/protobuf/4.33.5-release/protobuf/enum.Optional.html)
250251
* `fn set_foo(&mut self, val: i32)`: Sets the value of the field. After
251252
calling this, `has_foo()` will return `true` and `foo()` will return
252253
`value`.
@@ -271,12 +272,14 @@ The compiler generates the following accessor methods:
271272

272273
* `fn has_foo(&self) -> bool`: Returns `true` if the field is set.
273274
* `fn foo(&self) -> &protobuf::ProtoStr`: Returns the current value of the
274-
field. If the field is not set, it returns the default value.
275+
field. If the field is not set, it returns the default value. See
276+
[`ProtoStr` rustdoc](https://docs.rs/protobuf/4.33.5-release/protobuf/struct.ProtoStr.html).
275277
* `fn foo_opt(&self) -> protobuf::Optional<&ProtoStr>`: Returns an optional
276278
with the variant `Set(value)` if the field is set or `Unset(default value)`
277279
if it's unset.
278280
* `fn set_foo(&mut self, val: impl IntoProxied<ProtoString>)`: Sets the value
279-
of the field.
281+
of the field. `&str`, `String`, `&ProtoStr` and `ProtoString` all
282+
implelement `IntoProxied` and can be passed to this method.
280283
* `fn clear_foo(&mut self)`: Clears the value of the field. After calling
281284
this, `has_foo()` will return `false` and `foo()` will return the default
282285
value.
@@ -411,7 +414,8 @@ bytes bar = 2 [features.field_presence = IMPLICIT];
411414
The compiler will generate the following accessor methods:
412415

413416
* `fn foo(&self) -> &ProtoStr`: Returns the current value of the field. If the
414-
field is not set, returns the empty string/empty bytes.
417+
field is not set, returns the empty string/empty bytes. See
418+
[`ProtoStr` rustdoc](https://docs.rs/protobuf/4.33.5-release/protobuf/struct.ProtoStr.html).
415419
* `fn set_foo(&mut self, value: IntoProxied<ProtoString>)`: Sets the field to
416420
`value`.
417421

@@ -543,11 +547,15 @@ Given any of the above field definitions, the compiler generates the following
543547
accessor methods:
544548

545549
* `fn foo(&self) -> RepeatedView<'_, i32>`: Returns a view of the underlying
546-
repeated field.
550+
repeated field. See
551+
[`RepeatedView` rustdoc](https://docs.rs/protobuf/4.33.5-release/protobuf/struct.RepeatedView.html).
547552
* `fn foo_mut(&mut self) -> RepeatedMut<'_, i32>`: Returns a mutable handle to
548-
the underlying repeated field.
553+
the underlying repeated field. See
554+
[`RepeatedMut` rustdoc](https://docs.rs/protobuf/4.33.5-release/protobuf/struct.RepeatedMut.html).
549555
* `fn set_foo(&mut self, src: impl IntoProxied<Repeated<i32>>)`: Sets the
550-
underlying repeated field to a new repeated field provided in `src`.
556+
underlying repeated field to a new repeated field provided in `src`. Accepts
557+
a `RepeatedView`, `RepeatedMut` or `Repeated`. See
558+
[`Repeated` rustdoc](https://docs.rs/protobuf/4.33.5-release/protobuf/struct.Repeated.html).
551559

552560
For different field types only the respective generic types of the
553561
`RepeatedView`, `RepeatedMut` and `Repeated` types will change. For example,
@@ -565,11 +573,14 @@ map<int32, int32> weight = 1;
565573
The compiler will generate the following 3 accessor methods:
566574

567575
* `fn weight(&self) -> protobuf::MapView<'_, i32, i32>`: Returns an immutable
568-
view of the underlying map.
576+
view of the underlying map. See
577+
[`MapView` rustdoc](https://docs.rs/protobuf/4.33.5-release/protobuf/struct.MapView.html).
569578
* `fn weight_mut(&mut self) -> protobuf::MapMut<'_, i32, i32>`: Returns a
570-
mutable handle to the underlying map.
579+
mutable handle to the underlying map. See
580+
[`MapMut` rustdoc](https://docs.rs/protobuf/4.33.5-release/protobuf/struct.MapView.html).
571581
* `fn set_weight(&mut self, src: protobuf::IntoProxied<Map<i32, i32>>)`: Sets
572-
the underlying map to `src`.
582+
the underlying map to `src`. Accepts a `MapView`, `MapMut` or `Map`. See
583+
[`Map` rustdoc](https://docs.rs/protobuf/4.33.5-release/protobuf/struct.Map.html).
573584

574585
For different field types only the respective generic types of the `MapView`,
575586
`MapMut` and `Map` types will change. For example, given a field of type

0 commit comments

Comments
 (0)