Skip to content

Commit 99d4d0f

Browse files
committed
Update BUILD.bazel
adding rust_doc_test to ffi example
1 parent f329c0c commit 99d4d0f

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

examples/ffi/rust_calling_c/example_2/BUILD.bazel

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("@rules_rust//rust:defs.bzl", "rust_doc", "rust_library", "rust_test")
1+
load("@rules_rust//rust:defs.bzl", "rust_doc", "rust_doc_test", "rust_library", "rust_test")
22

33
package(default_visibility = ["//rust_calling_c/example_2:__subpackages__"])
44

@@ -24,6 +24,11 @@ rust_doc(
2424
crate = ":matrix",
2525
)
2626

27+
rust_doc_test(
28+
name = "matrix_doc_test",
29+
crate = ":matrix",
30+
)
31+
2732
## Do the same as above, but with a dynamic c library.
2833

2934
rust_library(

examples/ffi/rust_calling_c/example_2/src/matrix.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ pub struct Matrix {
2525
}
2626

2727
/// Wrapper around low-level FFI Matrix API.
28+
///
29+
/// Here is a simple example of how to use the Matrix struct:
30+
/// ```
31+
/// use matrix::Matrix;
32+
/// let matrix = Matrix::new(2, 4, &[11, 12, 13, 14, 21, 22, 23, 24]);
33+
/// assert_eq!(2, matrix.rows());
34+
/// assert_eq!(4, matrix.cols());
35+
/// ```
2836
impl Matrix {
2937
/// Constructs a new Matrix from the given data. Matrix returned contains a copy of the data
3038
/// provided.

0 commit comments

Comments
 (0)