Skip to content

Commit b00b261

Browse files
committed
feat: Updated rust docs
1 parent b2ca691 commit b00b261

File tree

1 file changed

+23
-22
lines changed
  • src/collections/_documentation/clients/rust

1 file changed

+23
-22
lines changed

src/collections/_documentation/clients/rust/index.md

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Sentry-Rust is distributed as a normal crate from crates.io. You can add it to y
1111

1212
```
1313
[dependencies]
14-
sentry = "0.6.0"
14+
sentry = "0.9.0"
1515
```
1616

1717
Additionally you can configure a bunch of features to enable or disable functionality in the crate. By default the most common features are compiled into the crate. For a list of features that are available refer to the [API Documentation](https://docs.rs/sentry).
@@ -20,32 +20,33 @@ Additionally you can configure a bunch of features to enable or disable function
2020

2121
The client is configured by calling `sentry::init` with a value that can be converted into a configuration object. These are the most common values:
2222

23-
- _an empty tuple_: in that case the client is configured from the `SENTRY_DSN` environment variable.
23+
- _an empty tuple_: in that case the client is configured from the `SENTRY_DSN` environment variably only.
2424
- _a string holding a DSN_: if you pass a string then a DSN is parsed and the client is initialized with that DSN.
2525
- _a tuple in the form (dsn, options)_: This is a form where the client is configured with a DSN plus an options object that allows you to configure additional features.
26+
- _just options_: In that case everything (including the DSN) are configured from the passed options.
2627

2728
This is the most common case for client configuration:
2829

2930
```rust
30-
extern crate sentry;
31+
extern crate sentry;
3132

3233
fn main() {
33-
sentry::init("___PUBLIC_DSN___");
34-
// code using sentry goes here.
34+
sentry::init("___PUBLIC_DSN___");
35+
// code using sentry goes here.
3536
}
3637
```
3738

3839
To configure releases automatically you can use the `sentry_crate_release!` macro in combination with the tuple config syntax:
3940

4041
```rust
41-
#[macro_use] extern crate sentry;
42+
#[macro_use] extern crate sentry;
4243

4344
fn main() {
44-
sentry::init(("___PUBLIC_DSN___", sentry::ClientOptions {
45-
release: sentry_crate_release!(),
46-
..Default::default()
47-
}));
48-
// code using sentry goes here.
45+
sentry::init(("___PUBLIC_DSN___", sentry::ClientOptions {
46+
release: sentry_crate_release!(),
47+
..Default::default()
48+
}));
49+
// code using sentry goes here.
4950
}
5051
```
5152

@@ -56,14 +57,14 @@ Once Sentry is configured errors and other events can be emitted. Since Rust has
5657
For instance to report a `failure::Error` this code can be used:
5758

5859
```rust
59-
use sentry::integrations::failure::capture_error;
60-
61-
let result = match a_function_that_might_fail() {
62-
Ok(val) => val,
63-
Err(err) => {
64-
capture_error(&err);
65-
return Err(err);
66-
}
60+
use sentry::integrations::failure::capture_error;
61+
62+
let result = match a_function_that_might_fail() {
63+
Ok(val) => val,
64+
Err(err) => {
65+
capture_error(&err);
66+
return Err(err);
67+
}
6768
};
6869
```
6970

@@ -75,8 +76,8 @@ To automatically catch panics the panic integration can be used:
7576
use sentry::integrations::panic::register_panic_handler;
7677

7778
fn main() {
78-
sentry::init(...);
79-
register_panic_handler();
79+
sentry::init(...);
80+
register_panic_handler();
8081
}
8182
```
8283

@@ -86,7 +87,7 @@ Since Sentry Rust uses a thread to offload event sending it’s possible that pe
8687

8788
```rust
8889
fn main() {
89-
let _guard = sentry::init(...);
90+
let _guard = sentry::init(...);
9091
}
9192
```
9293

0 commit comments

Comments
 (0)