Skip to content

Commit 0c35d88

Browse files
committed
Improve Session docs example
1 parent 7d7bd97 commit 0c35d88

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

crates/matrix-sdk-base/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ default-features = false
5050
features = ["sync", "fs"]
5151

5252
[dev-dependencies]
53+
anyhow = "1.0.45"
5354
futures = { version = "0.3.15", default-features = false }
5455
http = "0.2.4"
5556
matrix-sdk-test = { version = "0.4.0", path = "../matrix-sdk-test" }

crates/matrix-sdk-base/src/session.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,19 @@ use serde::{Deserialize, Serialize};
2525
///
2626
/// ```
2727
/// use matrix_sdk_base::Session;
28-
/// use ruma::UserId;
29-
/// use std::str::FromStr;
28+
/// use ruma::{DeviceIdBox, user_id};
3029
///
30+
/// # fn main() -> anyhow::Result<()> {
3131
/// let session = Session {
32-
/// access_token: String::from("abcdefgh012345678"),
33-
/// user_id: UserId::from_str("@name:example.com").unwrap(),
34-
/// device_id: "zyxwv54321".into(),
32+
/// access_token: "My-Token".to_owned(),
33+
/// user_id: user_id!("@example:localhost"),
34+
/// device_id: DeviceIdBox::from("MYDEVICEID"),
3535
/// };
3636
///
37-
/// assert_eq!(session.device_id.as_str(), "zyxwv54321");
37+
/// assert_eq!(session.device_id.as_str(), "MYDEVICEID");
38+
///
39+
/// # Ok(())
40+
/// # }
3841
/// ```
3942
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
4043
pub struct Session {

0 commit comments

Comments
 (0)