Skip to content

Commit 80fb5bc

Browse files
committed
test: fix nginx-sys doctests
1 parent 969c870 commit 80fb5bc

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

nginx-sys/src/lib.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424
//! ```rust,no_run
2525
//! use nginx_sys::nginx_version;
2626
//!
27-
//! let version = unsafe { nginx_version() };
28-
//! println!("Nginx version: {}", version);
27+
//! println!("Nginx version: {}", nginx_version);
2928
//! ```
3029
//!
3130
#![warn(missing_docs)]
@@ -77,7 +76,7 @@ pub unsafe fn bytes_to_uchar(pool: *mut ngx_pool_t, data: &[u8]) -> Option<*mut
7776
/// A raw pointer (`*mut u_char`) to the allocated memory containing the converted string data.
7877
///
7978
/// # Example
80-
/// ```rust
79+
/// ```rust,ignore
8180
/// let pool: *mut ngx_pool_t = ...; // Obtain a pointer to the nginx memory pool
8281
/// let data: &str = "example"; // The string to convert
8382
/// let ptr = str_to_uchar(pool, data);
@@ -237,11 +236,15 @@ impl TryFrom<ngx_str_t> for &str {
237236
///
238237
/// # Example
239238
/// ```rust
240-
/// let table: *mut ngx_table_elt_t = ...; // Obtain a pointer to the nginx table entry
241-
/// let pool: *mut ngx_pool_t = ...; // Obtain a pointer to the nginx memory pool
239+
/// # use nginx_sys::*;
240+
/// # unsafe fn example(pool: *mut ngx_pool_t, headers: *mut ngx_list_t) {
241+
/// // Obtain a pointer to the nginx table entry
242+
/// let table: *mut ngx_table_elt_t = ngx_list_push(headers).cast();
243+
/// assert!(!table.is_null());
242244
/// let key: &str = "key"; // The key to add
243245
/// let value: &str = "value"; // The value to add
244246
/// let result = add_to_ngx_table(table, pool, key, value);
247+
/// # }
245248
/// ```
246249
pub unsafe fn add_to_ngx_table(
247250
table: *mut ngx_table_elt_t,

0 commit comments

Comments
 (0)