Skip to content

Commit

Permalink
added docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jewlexx committed Sep 8, 2023
1 parent 954eee5 commit 946ff4b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions quork-proc/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
//! Quork procedural macros crate

#![warn(clippy::pedantic)]
#![warn(missing_docs)]

use proc_macro_error::proc_macro_error;
use syn::{parse_macro_input, DeriveInput, LitStr};
Expand Down Expand Up @@ -41,13 +44,19 @@ pub fn derive_new(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
new::derive(&ast).into()
}

/// Implement the [`std::convert::From`] trait for converting tuples into tuple structs
#[proc_macro_derive(FromTuple)]
#[proc_macro_error]
pub fn derive_from_tuple(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
let ast = parse_macro_input!(input as DeriveInput);
from_tuple::derive(&ast).into()
}

/// Time a given function
///
/// Measures the start and finish times of the function, and prints them at the end of the function.
///
/// You can pass "s", "ms", "ns"
#[proc_macro_attribute]
pub fn time(
args: proc_macro::TokenStream,
Expand All @@ -56,20 +65,23 @@ pub fn time(
time_fn::attribute(&args.into(), input.into()).into()
}

/// Strip whitespace from the right of a string literal on each line
#[proc_macro]
pub fn strip_lines(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
let literal = parse_macro_input!(input as LitStr);

strip::funclike(&literal, &strip::Alignment::None).into()
}

/// Strip whitespace from the left and right of a string literal on each line
#[proc_macro]
pub fn rstrip_lines(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
let literal = parse_macro_input!(input as LitStr);

strip::funclike(&literal, &strip::Alignment::Right).into()
}

/// Strip whitespace from the left of a string literal on each line
#[proc_macro]
pub fn lstrip_lines(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
let literal = parse_macro_input!(input as LitStr);
Expand Down

0 comments on commit 946ff4b

Please sign in to comment.