Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
GregoryKogan committed Jan 7, 2024
1 parent 3b02cf5 commit 10d0aca
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 17 deletions.
6 changes: 3 additions & 3 deletions docs/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ DOXYFILE_ENCODING = UTF-8
# title of most generated pages and in a few other places.
# The default value is: My Project.

PROJECT_NAME = "Result C++"
PROJECT_NAME = "result"

# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
# could be handy for archiving the generated documentation or if some version
Expand All @@ -54,7 +54,7 @@ PROJECT_NUMBER = 0.0.1
# for a project that appears at the top of each page and should give viewer a
# quick idea about the purpose of the project. Keep the description short.

PROJECT_BRIEF = "A modern C++ Result<T, E> type inspired by Rust"
PROJECT_BRIEF = "A C++ result<T, E> type inspired by Rust"

# With the PROJECT_LOGO tag one can specify a logo or an icon that is included
# in the documentation. The maximum height of the logo should not exceed 55
Expand Down Expand Up @@ -943,7 +943,7 @@ WARN_LOGFILE =
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
# Note: If this tag is empty the current directory is searched.

INPUT = src
INPUT = result.h

# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
Expand Down
30 changes: 23 additions & 7 deletions result.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
/// result is a C++ library that provides a Result<T, E> type, which can be used to return and propagate errors. It's
/// inspired by Rust's std::Result type.
/// @file
/// @brief result is a C++ library that provides a Result<T, E> type, which can be used to return and propagate
/// errors. It's inspired by Rust's std::Result type.
///
/// author: GregoryKogan
/// My github page: https://github.com/GregoryKogan
/// version: 0.0.0
/// date: 2023, December 21
/// This file contains the declaration of the Result class template.
/// @author GregoryKogan
/// @version 0.0.1
/// @date 2023, December 21
/// @par License
/// This software is released under the GNU GENERAL PUBLIC LICENSE Version 3.
/// @par Contact
/// My github page: https://github.com/GregoryKogan

#ifndef RESULT_LIB
#define RESULT_LIB
Expand All @@ -18,6 +22,9 @@ namespace res {
template <typename T, typename E> class result;
template <typename E> class result<void, E>;

/// @brief Err object represents an unsuccessful outcome and can be implicitly converted to a result.
/// @details Err object holds an error of type E. Err object can't be empty, E must not be std::monostate.
/// @tparam E Type of the error.
template <typename E> class err {
E error_;

Expand All @@ -41,6 +48,9 @@ namespace res {
template <typename T, typename E> class result;
template <typename E> class result<void, E>;

/// @brief Ok object represents a successful outcome and can be implicitly converted to a result.
/// @details Ok object holds a value of type T. Empty Ok object can be created if T is std::monostate.
/// @tparam T Type of the value. Defaults to std::monostate.
template <typename T = std::monostate> class ok {
T value_;

Expand All @@ -62,6 +72,12 @@ template <typename T> template <typename E> inline ok<T>::operator result<void,

namespace res {

/// @brief `result` is a type that represents either success or failure.
///
/// result<T, E> is the type used for returning and propagating errors. It holds either a successful value of type T or
/// an error of type E.
/// @tparam T
/// @tparam E
template <typename T, typename E> class result {
static_assert(!std::is_same_v<T, void>, "T (value type) must not be void");
static_assert(!std::is_same_v<E, void>, "E (error type) must not be void");
Expand All @@ -85,7 +101,7 @@ template <typename T, typename E> class result {
[[nodiscard]] auto error() const -> const E &;
};

// result class specialization for void value type
/// @brief `result` class specialization for void value type.
template <typename E> class result<void, E> {
static_assert(!std::is_same_v<E, void>, "E (error type) must not be void");

Expand Down
3 changes: 3 additions & 0 deletions src/err/err.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ namespace res {
template <typename T, typename E> class result;
template <typename E> class result<void, E>;

/// @brief Err object represents an unsuccessful outcome and can be implicitly converted to a result.
/// @details Err object holds an error of type E. Err object can't be empty, E must not be std::monostate.
/// @tparam E Type of the error.
template <typename E> class err {
E error_;

Expand Down
3 changes: 3 additions & 0 deletions src/ok/ok.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ namespace res {
template <typename T, typename E> class result;
template <typename E> class result<void, E>;

/// @brief Ok object represents a successful outcome and can be implicitly converted to a result.
/// @details Ok object holds a value of type T. Empty Ok object can be created if T is std::monostate.
/// @tparam T Type of the value. Defaults to std::monostate.
template <typename T = std::monostate> class ok {
T value_;

Expand Down
16 changes: 10 additions & 6 deletions src/result-wrapper.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
/// result is a C++ library that provides a Result<T, E> type, which can be used to return and propagate errors. It's
/// inspired by Rust's std::Result type.
/// @file
/// @brief result is a C++ library that provides a Result<T, E> type, which can be used to return and propagate
/// errors. It's inspired by Rust's std::Result type.
///
/// author: GregoryKogan
/// My github page: https://github.com/GregoryKogan
/// version: 0.0.0
/// date: 2023, December 21
/// This file contains the declaration of the Result class template.
/// @author GregoryKogan
/// @version 0.0.1
/// @date 2023, December 21
/// @par License
/// This software is released under the GNU GENERAL PUBLIC LICENSE Version 3.
/// @par Contact
/// My github page: https://github.com/GregoryKogan

#ifndef RESULT_LIB
#define RESULT_LIB
Expand Down
8 changes: 7 additions & 1 deletion src/result/result.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@

namespace res {

/// @brief `result` is a type that represents either success or failure.
///
/// result<T, E> is the type used for returning and propagating errors. It holds either a successful value of type T or
/// an error of type E.
/// @tparam T
/// @tparam E
template <typename T, typename E> class result {
static_assert(!std::is_same_v<T, void>, "T (value type) must not be void");
static_assert(!std::is_same_v<E, void>, "E (error type) must not be void");
Expand All @@ -31,7 +37,7 @@ template <typename T, typename E> class result {
[[nodiscard]] auto error() const -> const E &;
};

// result class specialization for void value type
/// @brief `result` class specialization for void value type.
template <typename E> class result<void, E> {
static_assert(!std::is_same_v<E, void>, "E (error type) must not be void");

Expand Down

0 comments on commit 10d0aca

Please sign in to comment.