Format code in doc comments
This commit is contained in:
parent
215cb35806
commit
41d6bcc2a6
12 changed files with 38 additions and 45 deletions
|
@ -1,4 +1,5 @@
|
|||
comment_width = 100
|
||||
format_code_in_doc_comments = true
|
||||
imports_granularity = "Crate"
|
||||
newline_style = "Unix"
|
||||
use_small_heuristics = "Max"
|
||||
|
|
|
@ -56,13 +56,16 @@
|
|||
//! # let client = MatrixClient::new(homeserver_url, None);
|
||||
//! use std::convert::TryFrom;
|
||||
//!
|
||||
//! use ruma_api::MatrixVersion;
|
||||
//! use ruma_client_api::alias::get_alias;
|
||||
//! use ruma_identifiers::{room_alias_id, room_id};
|
||||
//! use ruma_api::MatrixVersion;
|
||||
//!
|
||||
//! async {
|
||||
//! let response = client
|
||||
//! .send_request(get_alias::v3::Request::new(room_alias_id!("#example_room:example.com")), &[MatrixVersion::V1_0])
|
||||
//! .send_request(
|
||||
//! get_alias::v3::Request::new(room_alias_id!("#example_room:example.com")),
|
||||
//! &[MatrixVersion::V1_0],
|
||||
//! )
|
||||
//! .await?;
|
||||
//!
|
||||
//! assert_eq!(response.room_id, room_id!("!n8f893n9:example.com"));
|
||||
|
|
|
@ -9,7 +9,7 @@ use crate::generate_localpart;
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use ruma_identifiers::{DeviceId, device_id};
|
||||
/// use ruma_identifiers::{device_id, DeviceId};
|
||||
///
|
||||
/// let random_id = DeviceId::new();
|
||||
/// assert_eq!(random_id.as_str().len(), 8);
|
||||
|
|
|
@ -20,10 +20,7 @@ use crate::ServerName;
|
|||
/// # use std::convert::TryFrom;
|
||||
/// # use ruma_identifiers::EventId;
|
||||
/// // Original format
|
||||
/// assert_eq!(
|
||||
/// <&EventId>::try_from("$h29iv0s8:example.com").unwrap(),
|
||||
/// "$h29iv0s8:example.com"
|
||||
/// );
|
||||
/// assert_eq!(<&EventId>::try_from("$h29iv0s8:example.com").unwrap(), "$h29iv0s8:example.com");
|
||||
/// // Room version 3 format
|
||||
/// assert_eq!(
|
||||
/// <&EventId>::try_from("$acR1l0raoZnm60CBwAVgqbZqoO/mYU81xysh1u7XcJk").unwrap(),
|
||||
|
|
|
@ -10,10 +10,7 @@ use crate::{server_name::ServerName, EventId, MatrixToRef};
|
|||
/// ```
|
||||
/// # use std::convert::TryFrom;
|
||||
/// # use ruma_identifiers::RoomAliasId;
|
||||
/// assert_eq!(
|
||||
/// <&RoomAliasId>::try_from("#ruma:example.com").unwrap(),
|
||||
/// "#ruma:example.com"
|
||||
/// );
|
||||
/// assert_eq!(<&RoomAliasId>::try_from("#ruma:example.com").unwrap(), "#ruma:example.com");
|
||||
/// ```
|
||||
#[repr(transparent)]
|
||||
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
|
|
|
@ -10,10 +10,7 @@ use crate::{EventId, MatrixToRef, ServerName};
|
|||
/// ```
|
||||
/// # use std::convert::TryFrom;
|
||||
/// # use ruma_identifiers::RoomId;
|
||||
/// assert_eq!(
|
||||
/// <&RoomId>::try_from("!n8f893n9:example.com").unwrap(),
|
||||
/// "!n8f893n9:example.com"
|
||||
/// );
|
||||
/// assert_eq!(<&RoomId>::try_from("!n8f893n9:example.com").unwrap(), "!n8f893n9:example.com");
|
||||
/// ```
|
||||
#[repr(transparent)]
|
||||
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
|
|
|
@ -13,10 +13,7 @@ use crate::{server_name::ServerName, RoomAliasId, RoomId};
|
|||
/// ```
|
||||
/// # use std::convert::TryFrom;
|
||||
/// # use ruma_identifiers::RoomOrAliasId;
|
||||
/// assert_eq!(
|
||||
/// <&RoomOrAliasId>::try_from("#ruma:example.com").unwrap(),
|
||||
/// "#ruma:example.com"
|
||||
/// );
|
||||
/// assert_eq!(<&RoomOrAliasId>::try_from("#ruma:example.com").unwrap(), "#ruma:example.com");
|
||||
///
|
||||
/// assert_eq!(
|
||||
/// <&RoomOrAliasId>::try_from("!n8f893n9:example.com").unwrap(),
|
||||
|
|
|
@ -12,7 +12,8 @@ pub type EntitySignatures<K> = BTreeMap<Box<SigningKeyId<K>>, String>;
|
|||
/// let key_identifier = KeyId::from_parts(SigningKeyAlgorithm::Ed25519, "1");
|
||||
/// let mut signatures = Signatures::new();
|
||||
/// let server_name = server_name!("example.org");
|
||||
/// let signature = "YbJva03ihSj5mPk+CHMJKUKlCXCPFXjXOK6VqBnN9nA2evksQcTGn6hwQfrgRHIDDXO2le49x7jnWJHMJrJoBQ";
|
||||
/// let signature =
|
||||
/// "YbJva03ihSj5mPk+CHMJKUKlCXCPFXjXOK6VqBnN9nA2evksQcTGn6hwQfrgRHIDDXO2le49x7jnWJHMJrJoBQ";
|
||||
/// signatures.insert(server_name, key_identifier, signature.into());
|
||||
/// ```
|
||||
#[derive(Clone, Debug, Default)]
|
||||
|
|
|
@ -12,10 +12,7 @@ use crate::{MatrixToRef, ServerName};
|
|||
/// ```
|
||||
/// # use std::convert::TryFrom;
|
||||
/// # use ruma_identifiers::UserId;
|
||||
/// assert_eq!(
|
||||
/// <&UserId>::try_from("@carl:example.com").unwrap(),
|
||||
/// "@carl:example.com"
|
||||
/// );
|
||||
/// assert_eq!(<&UserId>::try_from("@carl:example.com").unwrap(), "@carl:example.com");
|
||||
/// ```
|
||||
#[repr(transparent)]
|
||||
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
|
@ -115,7 +112,8 @@ impl UserId {
|
|||
///
|
||||
/// let message = format!(
|
||||
/// r#"Thanks for the update <a href="{link}">{display_name}</a>."#,
|
||||
/// link = user_id!("@jplatte:notareal.hs").matrix_to_url(), display_name = "jplatte",
|
||||
/// link = user_id!("@jplatte:notareal.hs").matrix_to_url(),
|
||||
/// display_name = "jplatte",
|
||||
/// );
|
||||
/// ```
|
||||
pub fn matrix_to_url(&self) -> MatrixToRef<'_> {
|
||||
|
|
|
@ -31,8 +31,10 @@ use val_or_vec::ValOrVec;
|
|||
///
|
||||
/// assert_eq!(
|
||||
/// ruma_serde::urlencoded::from_bytes::<Vec<(String, String)>>(
|
||||
/// b"bread=baguette&cheese=comt%C3%A9&meat=ham&fat=butter"),
|
||||
/// Ok(meal));
|
||||
/// b"bread=baguette&cheese=comt%C3%A9&meat=ham&fat=butter"
|
||||
/// ),
|
||||
/// Ok(meal)
|
||||
/// );
|
||||
/// ```
|
||||
pub fn from_bytes<'de, T>(input: &'de [u8]) -> Result<T, Error>
|
||||
where
|
||||
|
@ -53,8 +55,10 @@ where
|
|||
///
|
||||
/// assert_eq!(
|
||||
/// ruma_serde::urlencoded::from_str::<Vec<(String, String)>>(
|
||||
/// "bread=baguette&cheese=comt%C3%A9&meat=ham&fat=butter"),
|
||||
/// Ok(meal));
|
||||
/// "bread=baguette&cheese=comt%C3%A9&meat=ham&fat=butter"
|
||||
/// ),
|
||||
/// Ok(meal)
|
||||
/// );
|
||||
/// ```
|
||||
pub fn from_str<'de, T>(input: &'de str) -> Result<T, Error>
|
||||
where
|
||||
|
|
|
@ -13,16 +13,12 @@ use serde::ser;
|
|||
/// Serializes a value into a `application/x-www-form-urlencoded` `String` buffer.
|
||||
///
|
||||
/// ```
|
||||
/// let meal = &[
|
||||
/// ("bread", "baguette"),
|
||||
/// ("cheese", "comté"),
|
||||
/// ("meat", "ham"),
|
||||
/// ("fat", "butter"),
|
||||
/// ];
|
||||
/// let meal = &[("bread", "baguette"), ("cheese", "comté"), ("meat", "ham"), ("fat", "butter")];
|
||||
///
|
||||
/// assert_eq!(
|
||||
/// ruma_serde::urlencoded::to_string(meal),
|
||||
/// Ok("bread=baguette&cheese=comt%C3%A9&meat=ham&fat=butter".to_owned()));
|
||||
/// Ok("bread=baguette&cheese=comt%C3%A9&meat=ham&fat=butter".to_owned())
|
||||
/// );
|
||||
/// ```
|
||||
pub fn to_string<T: ser::Serialize>(input: T) -> Result<String, Error> {
|
||||
let mut urlencoder = UrlEncodedSerializer::new("".to_owned());
|
||||
|
|
|
@ -116,7 +116,8 @@ static REFERENCE_HASH_FIELDS_TO_REMOVE: &[&str] = &["age_ts", "signatures", "uns
|
|||
/// let key_pair = ruma_signatures::Ed25519KeyPair::from_der(
|
||||
/// &document,
|
||||
/// "1".into(), // The "version" of the key.
|
||||
/// ).unwrap();
|
||||
/// )
|
||||
/// .unwrap();
|
||||
///
|
||||
/// // Deserialize some JSON.
|
||||
/// let mut value = serde_json::from_str("{}").unwrap();
|
||||
|
@ -191,11 +192,10 @@ where
|
|||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// let input =
|
||||
/// r#"{
|
||||
/// "本": 2,
|
||||
/// "日": 1
|
||||
/// }"#;
|
||||
/// let input = r#"{
|
||||
/// "本": 2,
|
||||
/// "日": 1
|
||||
/// }"#;
|
||||
///
|
||||
/// let object = serde_json::from_str(input).unwrap();
|
||||
/// let canonical = ruma_signatures::canonical_json(&object).unwrap();
|
||||
|
@ -430,7 +430,8 @@ pub fn reference_hash(
|
|||
/// let key_pair = Ed25519KeyPair::from_der(
|
||||
/// &document,
|
||||
/// "1".into(), // The "version" of the key.
|
||||
/// ).unwrap();
|
||||
/// )
|
||||
/// .unwrap();
|
||||
///
|
||||
/// // Deserialize an event from JSON.
|
||||
/// let mut object = serde_json::from_str(
|
||||
|
@ -449,8 +450,9 @@ pub fn reference_hash(
|
|||
/// "unsigned": {
|
||||
/// "age_ts": 1000000
|
||||
/// }
|
||||
/// }"#
|
||||
/// ).unwrap();
|
||||
/// }"#,
|
||||
/// )
|
||||
/// .unwrap();
|
||||
///
|
||||
/// // Hash and sign the JSON with the key pair.
|
||||
/// assert!(hash_and_sign_event("domain", &key_pair, &mut object, &RoomVersionId::V1).is_ok());
|
||||
|
|
Loading…
Reference in a new issue