Skip to content

Commit

Permalink
Fix macro docs (#3378)
Browse files Browse the repository at this point in the history
  • Loading branch information
kennykerr authored Dec 11, 2024
1 parent 0a68b66 commit f8124e8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
3 changes: 3 additions & 0 deletions crates/libs/implement/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ proc-macro = true
syn = { version = "2.0", default-features = false, features = ["parsing", "proc-macro", "printing", "full", "derive"] }
quote = "1.0"
proc-macro2 = "1.0"

[dev-dependencies]
windows-core = { path = "../core" }
14 changes: 5 additions & 9 deletions crates/libs/implement/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ use quote::{quote, ToTokens};
/// Implements one or more COM interfaces.
///
/// # Example
/// ```rust,no_run
/// use windows_core::*;
///
/// Here is a [more complete tutorial](https://kennykerr.ca/rust-getting-started/how-to-implement-com-interface.html).
///
/// ```rust,ignore
/// #[interface("094d70d6-5202-44b8-abb8-43860da5aca2")]
/// unsafe trait IValue: IUnknown {
/// fn GetValue(&self, value: *mut i32) -> HRESULT;
Expand All @@ -21,18 +20,15 @@ use quote::{quote, ToTokens};
/// #[implement(IValue)]
/// struct Value(i32);
///
/// impl IValue_Impl for Value {
/// impl IValue_Impl for Value_Impl {
/// unsafe fn GetValue(&self, value: *mut i32) -> HRESULT {
/// *value = self.0;
/// HRESULT(0)
/// }
/// }
///
/// fn main() {
/// let rust_instance = Value(123);
/// let com_object: IValue = rust_instance.into();
/// // You can now call interface methods on com_object.
/// }
/// let object: IValue = Value(123).into();
/// // Call interface methods...
/// ```
#[proc_macro_attribute]
pub fn implement(
Expand Down
3 changes: 3 additions & 0 deletions crates/libs/interface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ proc-macro = true
syn = { version = "2.0", default-features = false, features = ["parsing", "proc-macro", "printing", "full", "derive", "clone-impls"] }
quote = "1.0"
proc-macro2 = "1.0"

[dev-dependencies]
windows-core = { path = "../core" }
12 changes: 6 additions & 6 deletions crates/libs/interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ use syn::spanned::Spanned;
/// Defines a COM interface to call or implement.
///
/// # Example
/// ```rust,ignore
/// ```rust,no_run
/// use windows_core::*;
///
/// #[interface("094d70d6-5202-44b8-abb8-43860da5aca2")]
/// unsafe trait IValue: IUnknown {
/// fn GetValue(&self, value: *mut i32) -> HRESULT;
Expand All @@ -19,17 +21,15 @@ use syn::spanned::Spanned;
/// #[implement(IValue)]
/// struct Value(i32);
///
/// impl IValue_Impl for Value {
/// impl IValue_Impl for Value_Impl {
/// unsafe fn GetValue(&self, value: *mut i32) -> HRESULT {
/// *value = self.0;
/// HRESULT(0)
/// }
/// }
///
/// fn main() {
/// let object: IValue = Value(123).into();
/// // Call interface methods...
/// }
/// let object: IValue = Value(123).into();
/// // Call interface methods...
/// ```
#[proc_macro_attribute]
pub fn interface(
Expand Down

0 comments on commit f8124e8

Please sign in to comment.