Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

[libraries/pod]: improve PodOption type #7076

Merged
merged 3 commits into from
Jul 30, 2024

Conversation

febo
Copy link
Contributor

@febo febo commented Jul 30, 2024

Problem

The PodOption type currently has 2 limitations:

  1. It does not handle correctly the conversion of Option::Some(T::default()) to PodOption since T::default() corresponds to the None value. As a result, it will convert a Some to a None value.
  2. It always assume that T:default() is the None value, which might not be true in all cases and could be a limitation.

Solution

To address (1), replace the From implementation for a TryFrom, where the conversion will fail when trying to convert a Option::Some(T::default()) value to PodOption.

To address (2), add a new associated constant NONE to the Nullable trait instead of relying on the default value. Types implementing the trait can then specify the value that represents None.

@febo febo requested a review from joncinque July 30, 2024 12:26
@febo febo marked this pull request as ready for review July 30, 2024 13:04
Copy link
Contributor

@joncinque joncinque left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Just a couple of style nits

@febo febo requested a review from joncinque July 30, 2024 13:28
Copy link
Contributor

@joncinque joncinque left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great

@febo febo merged commit c1e3763 into solana-labs:master Jul 30, 2024
8 checks passed
@febo febo deleted the improve-pod-option branch July 30, 2024 13:56
joncinque added a commit to joncinque/solana-program-library that referenced this pull request Aug 27, 2024
#### Problem

The publish step is great, but there's still some manual work to add the
changelog and correct title for the created release.

#### Summary of changes

Use git-cliff to generate the release notes. This comes with a very
simple cliff.toml which will do minimal processing, since we don't
follow conventional commits in the repo.

Here's a test run for the given input:

```
$ git-cliff -c ci/cliff.toml "pod-v0.3.0"..master --include-path "libraries/pod/**" --github-repo "solana-labs/solana-program-library"
```

Output:

```
## What's new

- Publish pod v0.3.2 by @github-actions[bot]
- [token-2022] Upgrade to `zk-sdk` (solana-labs#7148) by @samkim-crypto
- Implement `Default` for `PodOption` (solana-labs#7083) by @joncinque
- Bump to 0.3.1 (solana-labs#7075) by @febo
- Improve `PodOption` type (solana-labs#7076) by @febo
- Add `PodU128` type (solana-labs#7012) by @febo
- Add `PodOption` type (solana-labs#6886) by @febo
- Use `bytemuck_derive` explicitly (solana-labs#6928) by @joncinque
```
joncinque added a commit that referenced this pull request Aug 28, 2024
* CI: Add git-cliff step during publish

#### Problem

The publish step is great, but there's still some manual work to add the
changelog and correct title for the created release.

#### Summary of changes

Use git-cliff to generate the release notes. This comes with a very
simple cliff.toml which will do minimal processing, since we don't
follow conventional commits in the repo.

Here's a test run for the given input:

```
$ git-cliff -c ci/cliff.toml "pod-v0.3.0"..master --include-path "libraries/pod/**" --github-repo "solana-labs/solana-program-library"
```

Output:

```
## What's new

- Publish pod v0.3.2 by @github-actions[bot]
- [token-2022] Upgrade to `zk-sdk` (#7148) by @samkim-crypto
- Implement `Default` for `PodOption` (#7083) by @joncinque
- Bump to 0.3.1 (#7075) by @febo
- Improve `PodOption` type (#7076) by @febo
- Add `PodU128` type (#7012) by @febo
- Add `PodOption` type (#6886) by @febo
- Use `bytemuck_derive` explicitly (#6928) by @joncinque
```

* Don't always run the step

* Make the YAML valid

* Trim each commit line to just the first line
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants