Remove monadic functions from coral::expected
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
468ff1a510
commit
4700c143cc
@ -398,13 +398,6 @@ export namespace coral {
|
|||||||
(*reinterpret_cast<errors *>(this->buffer)) = error;
|
(*reinterpret_cast<errors *>(this->buffer)) = error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Invokes the `apply` procedure if the expected is not ok, otherwise having no side-effects.
|
|
||||||
*/
|
|
||||||
void and_then(closure<void(expects &)> const & apply) {
|
|
||||||
if (this->is_ok()) apply(*this->ok());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the contained error as an [optional].
|
* Returns the contained error as an [optional].
|
||||||
*/
|
*/
|
||||||
|
@ -21,7 +21,7 @@ extern "C" int main(int argc, char const * const * argv) {
|
|||||||
bool is_config_loaded {false};
|
bool is_config_loaded {false};
|
||||||
|
|
||||||
archive_file.read_file(config_path, [&](coral::file_reader & config_reader) {
|
archive_file.read_file(config_path, [&](coral::file_reader & config_reader) {
|
||||||
archive_file.query_file(config_path).and_then([&](coral::file_system::file_info file_info) {
|
archive_file.query_file(config_path).ok().and_then([&](coral::file_system::file_info file_info) {
|
||||||
turtle::system_allocator allocator {turtle::system_allocator::thread_safety::none};
|
turtle::system_allocator allocator {turtle::system_allocator::thread_safety::none};
|
||||||
coral::ring_buffer config_source;
|
coral::ring_buffer config_source;
|
||||||
|
|
||||||
|
@ -402,7 +402,7 @@ export namespace turtle {
|
|||||||
void read_file(slice<char const> const & path, closure<void(coral::file_reader &)> const & then) override {
|
void read_file(slice<char const> const & path, closure<void(coral::file_reader &)> const & then) override {
|
||||||
if (!this->access_permissions.can_read) return;
|
if (!this->access_permissions.can_read) return;
|
||||||
|
|
||||||
this->path.joined(path).and_then([&](native_path const & native_file_path) -> void {
|
this->path.joined(path).ok().and_then([&](native_path const & native_file_path) -> void {
|
||||||
native_file file;
|
native_file file;
|
||||||
|
|
||||||
if (file.open(native_file_path, native_file::open_mode::read_only) != open_result::ok) return;
|
if (file.open(native_file_path, native_file::open_mode::read_only) != open_result::ok) return;
|
||||||
@ -421,7 +421,7 @@ export namespace turtle {
|
|||||||
void walk_files(slice<char const> const & path, closure<void(coral::file_walker &)> const & then) override {
|
void walk_files(slice<char const> const & path, closure<void(coral::file_walker &)> const & then) override {
|
||||||
if (!this->access_permissions.can_walk) return;
|
if (!this->access_permissions.can_walk) return;
|
||||||
|
|
||||||
this->path.joined(path).and_then([&](native_path const & native_directory_path) -> void {
|
this->path.joined(path).ok().and_then([&](native_path const & native_directory_path) -> void {
|
||||||
// TODO: Implement.
|
// TODO: Implement.
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -434,7 +434,7 @@ export namespace turtle {
|
|||||||
void write_file(slice<char const> const & path, closure<void(coral::file_writer &)> const & then) override {
|
void write_file(slice<char const> const & path, closure<void(coral::file_writer &)> const & then) override {
|
||||||
if (!this->access_permissions.can_write) return;
|
if (!this->access_permissions.can_write) return;
|
||||||
|
|
||||||
this->path.joined(path).and_then([&](native_path const & native_file_path) -> void {
|
this->path.joined(path).ok().and_then([&](native_path const & native_file_path) -> void {
|
||||||
native_file file;
|
native_file file;
|
||||||
|
|
||||||
if (file.open(native_file_path, native_file::open_mode::overwrite) != open_result::ok) return;
|
if (file.open(native_file_path, native_file::open_mode::overwrite) != open_result::ok) return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user