Skip to content

Commit a460b69

Browse files
committed
docs: Add explanation on Request for BTreeSet<(K, V)>
1 parent ebac913 commit a460b69

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

oauth1-request/src/lib.rs

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,33 @@
7171
//! );
7272
//! ```
7373
//!
74+
//! See [`Request`][oauth1_request_derive::Request] for more details on the derive macro.
75+
//!
76+
//! If you want to authorize a request with dynamic keys, you can use a
77+
//! [`BTreeSet<(K, V)>`][std::collections::BTreeSet]:
78+
//!
79+
//! ```
80+
//! # extern crate oauth1_request as oauth;
81+
//! #
82+
//! use std::collections::BTreeSet;
83+
//!
84+
//! let request: BTreeSet<_> = vec![
85+
//! ("article_id", "123456789"),
86+
//! ("text", "A request signed with OAuth & Rust 🦀 🔏"),
87+
//! ]
88+
//! .into_iter()
89+
//! .collect();
90+
//!
91+
//! let form = oauth::to_form_urlencoded(&request);
92+
//! assert_eq!(
93+
//! form,
94+
//! "article_id=123456789&text=A%20request%20signed%20with%20OAuth%20%26%20Rust%20%F0%9F%A6%80%20%F0%9F%94%8F",
95+
//! );
96+
//! ```
97+
//!
7498
//! Use [`oauth::Builder`][Builder] if you need to specify a callback URI or verifier:
7599
//!
76-
//! ```rust
100+
//! ```
77101
//! # extern crate oauth1_request as oauth;
78102
//! #
79103
//! let uri = "https://example.com/oauth/request_temp_credentials";
@@ -85,8 +109,6 @@
85109
//! .callback(callback)
86110
//! .post(uri, &());
87111
//! ```
88-
//!
89-
//! See [`Request`][oauth1_request_derive::Request] for more details on the derive macro.
90112
91113
#![cfg_attr(docsrs, feature(doc_cfg, doc_cfg_hide))]
92114
#![doc(html_root_url = "https://docs.rs/oauth1-request/0.5.1")]

0 commit comments

Comments
 (0)