refactor: use newtype pattern for email addresses
Type of Change
- [ ] Bugfix
- [x] New feature
- [x] Enhancement
- [ ] Refactoring
- [ ] Dependency updates
Description
- This fixes #608
- Added testcases
Additional Changes
- [ ] This PR modifies the database schema
- [ ] This PR modifies application configuration/environment variables
Motivation and Context
#608
How did you test it?
- ran
cargo test - Added 2 unit testcases for validation of implemented code

Checklist
- [x] I formatted the code
cargo +nightly fmt --all - [x] I addressed lints thrown by
cargo clippy - [x] I reviewed submitted code
- [x] I added unit tests for my changes where possible
- [x] I added a CHANGELOG entry if applicable
- Shouldn't std::fmt::Debug be implemented for struct Email(Secret<String>)? Since, we will be calling format!(email) where email: Email(Secret<String>)
- So, Email(Secret<String>) will replace both Email(String) and Secret<String, Email>? @SanchithHegde
- Shouldn't std::fmt::Debug be implemented for struct Email(Secret)? Since, we will be calling format!(email) where email: Email(Secret)
You should be able to derive Debug on Email(Secret<String>) since Secret implements Debug already.
- So, Email(Secret) will replace both Email(String) and Secret<String, Email>?
I'm not sure if there are any types of the form Email(String) in our code. But if there are any, please do replace that and Secret<String, Email> with Email(Secret<String>).
let secret: Secret<String, Email> = Secret::new("[email protected]".to_string());
assert_eq!("*******@gmail.com", format!("{secret:?}"));
What about these tests?
You'd have to update/remove tests accordingly.
Sorry, this got closed by mistake. I was trying to sync with the remote, but somehow the PR closed.
Done
Done Made suggested changes