diff options
Diffstat (limited to 'book/src/binding')
-rw-r--r-- | book/src/binding/box.md | 14 | ||||
-rw-r--r-- | book/src/binding/cxxstring.md | 2 | ||||
-rw-r--r-- | book/src/binding/fn.md | 10 | ||||
-rw-r--r-- | book/src/binding/result.md | 30 | ||||
-rw-r--r-- | book/src/binding/slice.md | 78 | ||||
-rw-r--r-- | book/src/binding/str.md | 16 | ||||
-rw-r--r-- | book/src/binding/string.md | 16 | ||||
-rw-r--r-- | book/src/binding/vec.md | 142 |
8 files changed, 154 insertions, 154 deletions
diff --git a/book/src/binding/box.md b/book/src/binding/box.md index 7df19597..dc478999 100644 --- a/book/src/binding/box.md +++ b/book/src/binding/box.md @@ -3,12 +3,12 @@ ### Public API: -```cpp,hidelines +```cpp,hidelines=... // rust/cxx.h -# -# #include <type_traits> -# -# namespace rust { +... +...#include <type_traits> +... +...namespace rust { template <typename T> class Box final { @@ -42,8 +42,8 @@ public: T *into_raw() noexcept; }; -# -# } // namespace rust +... +...} // namespace rust ``` ### Restrictions: diff --git a/book/src/binding/cxxstring.md b/book/src/binding/cxxstring.md index cfe707f2..dc2619ce 100644 --- a/book/src/binding/cxxstring.md +++ b/book/src/binding/cxxstring.md @@ -134,7 +134,7 @@ std::unique_ptr<json> load_config() { std::in_place_type<json::object>, std::initializer_list<std::pair<const std::string, json>>{ {"name", "cxx-example"}, - {"edition", 2018.}, + {"edition", 2021.}, {"repository", json::null}}); } ``` diff --git a/book/src/binding/fn.md b/book/src/binding/fn.md index 2934b069..a32ad52a 100644 --- a/book/src/binding/fn.md +++ b/book/src/binding/fn.md @@ -3,10 +3,10 @@ ### Public API: -```cpp,hidelines +```cpp,hidelines=... // rust/cxx.h -# -# namespace rust { +... +...namespace rust { template <typename Signature> class Fn; @@ -17,8 +17,8 @@ public: Ret operator()(Args... args) const noexcept; Fn operator*() const noexcept; }; -# -# } // namespace rust +... +...} // namespace rust ``` ### Restrictions: diff --git a/book/src/binding/result.md b/book/src/binding/result.md index e49dcf4d..733212a6 100644 --- a/book/src/binding/result.md +++ b/book/src/binding/result.md @@ -55,10 +55,10 @@ The exception that gets thrown by CXX on the C++ side is always of type `rust::Error` and has the following C++ public API. The `what()` member function gives the error message according to the Rust error's std::fmt::Display impl. -```cpp,hidelines +```cpp,hidelines=... // rust/cxx.h -# -# namespace rust { +... +...namespace rust { class Error final : public std::exception { public: @@ -71,8 +71,8 @@ public: const char *what() const noexcept override; }; -# -# } // namespace rust +... +...} // namespace rust ``` ## Returning Result from C++ to Rust @@ -114,7 +114,7 @@ headers `include!`'d by your cxx::bridge. The template signature is required to be: -```cpp,hidelines +```cpp namespace rust { namespace behavior { @@ -130,19 +130,19 @@ following. You must follow the same pattern: invoke `func` with no arguments, catch whatever exception(s) you want, and invoke `fail` with the error message you'd like for the Rust error to have. -```cpp,hidelines -# #include <exception> -# -# namespace rust { -# namespace behavior { -# +```cpp,hidelines=... +...#include <exception> +... +...namespace rust { +...namespace behavior { +... template <typename Try, typename Fail> static void trycatch(Try &&func, Fail &&fail) noexcept try { func(); } catch (const std::exception &e) { fail(e.what()); } -# -# } // namespace behavior -# } // namespace rust +... +...} // namespace behavior +...} // namespace rust ``` diff --git a/book/src/binding/slice.md b/book/src/binding/slice.md index 803277ba..0de96273 100644 --- a/book/src/binding/slice.md +++ b/book/src/binding/slice.md @@ -6,13 +6,13 @@ ### Public API: -```cpp,hidelines +```cpp,hidelines=... // rust/cxx.h -# -# #include <iterator> -# #include <type_traits> -# -# namespace rust { +... +...#include <iterator> +...#include <type_traits> +... +...namespace rust { template <typename T> class Slice final { @@ -43,39 +43,39 @@ public: void swap(Slice &) noexcept; }; -# -# template <typename T> -# class Slice<T>::iterator final { -# public: -# using iterator_category = std::random_access_iterator_tag; -# using value_type = T; -# using pointer = T *; -# using reference = T &; -# -# T &operator*() const noexcept; -# T *operator->() const noexcept; -# T &operator[](ptrdiff_t) const noexcept; -# -# iterator &operator++() noexcept; -# iterator operator++(int) noexcept; -# iterator &operator--() noexcept; -# iterator operator--(int) noexcept; -# -# iterator &operator+=(ptrdiff_t) noexcept; -# iterator &operator-=(ptrdiff_t) noexcept; -# iterator operator+(ptrdiff_t) const noexcept; -# iterator operator-(ptrdiff_t) const noexcept; -# ptrdiff_t operator-(const iterator &) const noexcept; -# -# bool operator==(const iterator &) const noexcept; -# bool operator!=(const iterator &) const noexcept; -# bool operator<(const iterator &) const noexcept; -# bool operator>(const iterator &) const noexcept; -# bool operator<=(const iterator &) const noexcept; -# bool operator>=(const iterator &) const noexcept; -# }; -# -# } // namespace rust +... +...template <typename T> +...class Slice<T>::iterator final { +...public: +... using iterator_category = std::random_access_iterator_tag; +... using value_type = T; +... using pointer = T *; +... using reference = T &; +... +... T &operator*() const noexcept; +... T *operator->() const noexcept; +... T &operator[](ptrdiff_t) const noexcept; +... +... iterator &operator++() noexcept; +... iterator operator++(int) noexcept; +... iterator &operator--() noexcept; +... iterator operator--(int) noexcept; +... +... iterator &operator+=(ptrdiff_t) noexcept; +... iterator &operator-=(ptrdiff_t) noexcept; +... iterator operator+(ptrdiff_t) const noexcept; +... iterator operator-(ptrdiff_t) const noexcept; +... ptrdiff_t operator-(const iterator &) const noexcept; +... +... bool operator==(const iterator &) const noexcept; +... bool operator!=(const iterator &) const noexcept; +... bool operator<(const iterator &) const noexcept; +... bool operator>(const iterator &) const noexcept; +... bool operator<=(const iterator &) const noexcept; +... bool operator>=(const iterator &) const noexcept; +...}; +... +...} // namespace rust ``` ### Restrictions: diff --git a/book/src/binding/str.md b/book/src/binding/str.md index 9c1e0a77..66284562 100644 --- a/book/src/binding/str.md +++ b/book/src/binding/str.md @@ -3,13 +3,13 @@ ### Public API: -```cpp,hidelines +```cpp,hidelines=... // rust/cxx.h -# -# #include <iosfwd> -# #include <string> -# -# namespace rust { +... +...#include <iosfwd> +...#include <string> +... +...namespace rust { class Str final { public: @@ -50,8 +50,8 @@ public: }; std::ostream &operator<<(std::ostream &, const Str &); -# -# } // namespace rust +... +...} // namespace rust ``` ### Notes: diff --git a/book/src/binding/string.md b/book/src/binding/string.md index 1e482781..57dd245b 100644 --- a/book/src/binding/string.md +++ b/book/src/binding/string.md @@ -3,13 +3,13 @@ ### Public API: -```cpp,hidelines +```cpp,hidelines=... // rust/cxx.h -# -# #include <iosfwd> -# #include <string> -# -# namespace rust { +... +...#include <iosfwd> +...#include <string> +... +...namespace rust { class String final { public: @@ -73,8 +73,8 @@ public: }; std::ostream &operator<<(std::ostream &, const String &); -# -# } // namespace rust +... +...} // namespace rust ``` ### Restrictions: diff --git a/book/src/binding/vec.md b/book/src/binding/vec.md index 4d6587ab..af739b9f 100644 --- a/book/src/binding/vec.md +++ b/book/src/binding/vec.md @@ -3,14 +3,14 @@ ### Public API: -```cpp,hidelines +```cpp,hidelines=... // rust/cxx.h -# -# #include <initializer_list> -# #include <iterator> -# #include <type_traits> -# -# namespace rust { +... +...#include <initializer_list> +...#include <iterator> +...#include <type_traits> +... +...namespace rust { template <typename T> class Vec final { @@ -62,70 +62,70 @@ public: void swap(Vec &) noexcept; }; -# -# template <typename T> -# class Vec<T>::iterator final { -# public: -# using iterator_category = std::random_access_iterator_tag; -# using value_type = T; -# using pointer = T *; -# using reference = T &; -# -# T &operator*() const noexcept; -# T *operator->() const noexcept; -# T &operator[](ptrdiff_t) const noexcept; -# -# iterator &operator++() noexcept; -# iterator operator++(int) noexcept; -# iterator &operator--() noexcept; -# iterator operator--(int) noexcept; -# -# iterator &operator+=(ptrdiff_t) noexcept; -# iterator &operator-=(ptrdiff_t) noexcept; -# iterator operator+(ptrdiff_t) const noexcept; -# iterator operator-(ptrdiff_t) const noexcept; -# ptrdiff_t operator-(const iterator &) const noexcept; -# -# bool operator==(const iterator &) const noexcept; -# bool operator!=(const iterator &) const noexcept; -# bool operator<(const iterator &) const noexcept; -# bool operator<=(const iterator &) const noexcept; -# bool operator>(const iterator &) const noexcept; -# bool operator>=(const iterator &) const noexcept; -# }; -# -# template <typename T> -# class Vec<T>::const_iterator final { -# public: -# using iterator_category = std::random_access_iterator_tag; -# using value_type = const T; -# using pointer = const T *; -# using reference = const T &; -# -# const T &operator*() const noexcept; -# const T *operator->() const noexcept; -# const T &operator[](ptrdiff_t) const noexcept; -# -# const_iterator &operator++() noexcept; -# const_iterator operator++(int) noexcept; -# const_iterator &operator--() noexcept; -# const_iterator operator--(int) noexcept; -# -# const_iterator &operator+=(ptrdiff_t) noexcept; -# const_iterator &operator-=(ptrdiff_t) noexcept; -# const_iterator operator+(ptrdiff_t) const noexcept; -# const_iterator operator-(ptrdiff_t) const noexcept; -# ptrdiff_t operator-(const const_iterator &) const noexcept; -# -# bool operator==(const const_iterator &) const noexcept; -# bool operator!=(const const_iterator &) const noexcept; -# bool operator<(const const_iterator &) const noexcept; -# bool operator<=(const const_iterator &) const noexcept; -# bool operator>(const const_iterator &) const noexcept; -# bool operator>=(const const_iterator &) const noexcept; -# }; -# -# } // namespace rust +... +...template <typename T> +...class Vec<T>::iterator final { +...public: +... using iterator_category = std::random_access_iterator_tag; +... using value_type = T; +... using pointer = T *; +... using reference = T &; +... +... T &operator*() const noexcept; +... T *operator->() const noexcept; +... T &operator[](ptrdiff_t) const noexcept; +... +... iterator &operator++() noexcept; +... iterator operator++(int) noexcept; +... iterator &operator--() noexcept; +... iterator operator--(int) noexcept; +... +... iterator &operator+=(ptrdiff_t) noexcept; +... iterator &operator-=(ptrdiff_t) noexcept; +... iterator operator+(ptrdiff_t) const noexcept; +... iterator operator-(ptrdiff_t) const noexcept; +... ptrdiff_t operator-(const iterator &) const noexcept; +... +... bool operator==(const iterator &) const noexcept; +... bool operator!=(const iterator &) const noexcept; +... bool operator<(const iterator &) const noexcept; +... bool operator<=(const iterator &) const noexcept; +... bool operator>(const iterator &) const noexcept; +... bool operator>=(const iterator &) const noexcept; +...}; +... +...template <typename T> +...class Vec<T>::const_iterator final { +...public: +... using iterator_category = std::random_access_iterator_tag; +... using value_type = const T; +... using pointer = const T *; +... using reference = const T &; +... +... const T &operator*() const noexcept; +... const T *operator->() const noexcept; +... const T &operator[](ptrdiff_t) const noexcept; +... +... const_iterator &operator++() noexcept; +... const_iterator operator++(int) noexcept; +... const_iterator &operator--() noexcept; +... const_iterator operator--(int) noexcept; +... +... const_iterator &operator+=(ptrdiff_t) noexcept; +... const_iterator &operator-=(ptrdiff_t) noexcept; +... const_iterator operator+(ptrdiff_t) const noexcept; +... const_iterator operator-(ptrdiff_t) const noexcept; +... ptrdiff_t operator-(const const_iterator &) const noexcept; +... +... bool operator==(const const_iterator &) const noexcept; +... bool operator!=(const const_iterator &) const noexcept; +... bool operator<(const const_iterator &) const noexcept; +... bool operator<=(const const_iterator &) const noexcept; +... bool operator>(const const_iterator &) const noexcept; +... bool operator>=(const const_iterator &) const noexcept; +...}; +... +...} // namespace rust ``` ### Restrictions: |