# `RustQ.Test`
[🔗](https://github.com/elixir-crab/rustq/blob/v1.0.0-rc.19/lib/rustq/test.ex#L1)

Composable ExUnit helpers for Rust generated by `defrust` and `defnif`.

The helpers return source or boolean values so tests keep using ExUnit's
ordinary `assert` macro, pattern matching, and diffs:

    defmodule MyApp.NativeTest do
      use RustQ.Test, async: true

      test "generates and exports the native boundary" do
        assert rust_source!(MyApp.Native, :sum_impl) =~ "fn sum_impl"
        assert nif_exported?(MyApp.Native, :sum, 1)
        assert RustQ.valid?(rust_source!(MyApp.Native), "my_app_native.rs")
      end
    end

`rust_source!/1` returns a module's complete generated Rust.
`rust_source!/2` renders one named generated function, which keeps source
assertions focused and prevents matches across unrelated functions.

# `nif_exported?`

```elixir
@spec nif_exported?(module(), atom(), arity()) :: boolean()
```

Returns whether a function is exported to Elixir and marked as a Rustler NIF.

# `rust_source!`

```elixir
@spec rust_source!(module()) :: String.t()
```

Returns a generated module's complete Rust source or raises.

# `rust_source!`

```elixir
@spec rust_source!(module(), atom()) :: String.t()
```

Renders one named generated Rust function or raises.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
