Remove monadic functions from coral::expected
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
kayomn 2023-03-03 17:09:00 +00:00
parent 468ff1a510
commit 4700c143cc
3 changed files with 4 additions and 11 deletions

View File

@ -398,13 +398,6 @@ export namespace coral {
(*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].
*/

View File

@ -21,7 +21,7 @@ extern "C" int main(int argc, char const * const * argv) {
bool is_config_loaded {false};
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};
coral::ring_buffer config_source;

View File

@ -402,7 +402,7 @@ export namespace turtle {
void read_file(slice<char const> const & path, closure<void(coral::file_reader &)> const & then) override {
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;
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 {
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.
});
}
@ -434,7 +434,7 @@ export namespace turtle {
void write_file(slice<char const> const & path, closure<void(coral::file_writer &)> const & then) override {
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;
if (file.open(native_file_path, native_file::open_mode::overwrite) != open_result::ok) return;