Generalizing Option Macro Behaviour to OptionalValue Trait ?

Open
#322 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
rust
Domain
tooling

Research direction

Review the existing Option macro behavior and the Nullable YAML-parsing example described in the issue first. The issue names no files or tests; before implementation, settle the OptionalValue design and define the expected behavior for custom optional-like types.

Written by the indexing model from the issue text.

Description

We had a specific use-case, where for YAML parsing we have a custom type namely "Nullable" as the following structure:

pub enum Nullable<T> {
    /// Null value
    Null,
    /// Value is present
    Present(T),
}

This type behaves similar to Option type. Should we move towards generalizing the behaviour of the option type to any type that implements OptionalValue trait, which will define how to extract nested value for any type T.

trait OptionalValue {
    type Value;
    fn extract(&self) -> Option<Self::Value>;
}

?

Dominant language
Rust
Stars
2.5k
Forks
190
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Keats/validator

All issues in Keats/validator

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.