Skip to content

Commit

Permalink
Make doc tests pass
Browse files Browse the repository at this point in the history
Didn't know these would immediately be treated as tests
  • Loading branch information
Vurv78 committed Dec 9, 2021
1 parent 42dbf4d commit 4c76f24
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
/// Will panic if passed an expression that a CString could not be created from.
/// # Examples
/// ```rust
/// use rglua::prelude::*;
/// let a = b"Hello world!".as_ptr() as *const i8;
/// let b = cstr!("Hello world!");
/// assert_eq!(*a, *b);
/// unsafe { assert_eq!(*a, *b) };
/// ```
#[macro_export]
macro_rules! cstr {
Expand All @@ -26,9 +27,10 @@ macro_rules! cstr {
/// or if it is a value, makes a cstring and returns the pointer to it.
/// # Examples
/// ```rust
/// use rglua::prelude::*;
/// let a = b"Hello world!".as_ptr() as *const i8;
/// let b = try_cstr!("Hello world!");
/// assert_eq!(*a, *b.unwrap());
/// unsafe { assert_eq!(*a, *b) } ;
/// ```
#[macro_export]
macro_rules! try_cstr {
Expand All @@ -45,6 +47,7 @@ macro_rules! try_cstr {
/// Will panic if the const char* is not valid utf-8
/// # Examples
/// ```rust
/// use rglua::prelude::*;
/// let cstr = cstr!("Hello World");
/// let rust_str = rstr!(cstr);
/// assert_eq!(rust_str, "Hello World");
Expand All @@ -62,9 +65,10 @@ macro_rules! rstr {
/// Tries to convert a const char* to an &str
/// # Examples
/// ```rust
/// use rglua::prelude::*;
/// let cstr = cstr!("Hello World");
/// let rstr = try_rstr!(cstr);
/// assert(rstr.is_ok()); // Should be perfectly valid to convert to utf8
/// assert!(rstr.is_ok()); // Should be perfectly valid to convert to utf8
/// ```
macro_rules! try_rstr {
($cstring:expr) => {{
Expand All @@ -81,7 +85,8 @@ macro_rules! try_rstr {
/// Rest are varargs.
/// Can be either a variable storing a str literal, or a referenced String / str variable
/// # Examples
/// ```rust
/// ```ignore
/// use rglua::prelude::*;
/// printgm!(state, "Hello {}!", "world");
/// ```
macro_rules! printgm {
Expand All @@ -101,9 +106,12 @@ macro_rules! printgm {
/// # Examples
/// Basic usage
/// ```rust
/// use rglua::prelude::*;
/// extern "C" fn max(l: LuaState) -> i32 { 0 }
/// extern "C" fn min(l: LuaState) -> i32 { 0 }
/// let my_library = reg! [
/// "max" = max,
/// "min" = min,
/// "max" => max,
/// "min" => min
/// ];
/// ```
/// Returns a &[crate::types::LuaReg]
Expand Down

0 comments on commit 4c76f24

Please sign in to comment.