Skip to content

Commit

Permalink
temp commit
Browse files Browse the repository at this point in the history
  • Loading branch information
turboladen committed Jun 13, 2024
1 parent 898abcb commit 39def96
Show file tree
Hide file tree
Showing 26 changed files with 5,631 additions and 1,494 deletions.
30 changes: 30 additions & 0 deletions crates/api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,36 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [unreleased]

### Added

- `crate::Annotation` now wraps `String`s inside `Term`s.
- New type: `crate::term::Builder`. Intended for internal use only, but had to make public to
use it in the `term!()` macro.

### Changed

- `Term` refactored from `struct` to `enum` to represent only valid combinations of `factor`,
`prefix`, `atom`, `exponent`, and `annotation`.
- `Term` fields (`factor`, `prefix`, `atom`, `exponent`, `annotation`) now only accessible
via accessor method.
- `Term::new()` panics if passed only a `Prefix` (and no `Atom`).
- `Term::is_unity()` is now `const`.
- `impl Default for Term` now returns `term::UNITY` instead of a `Term` with 0 fields set.
- `term!()` can now take, for `annotation`, any `T: ToString`.
- (Internal) `AnnotationComposition` now uses `&str` instead of `String` when determining an
annotated `Term`'s composition.

### Removed

- `Term::has_value()` removed because this behavior is now encoded in the type.
- Removed because was initially erroneously made `pub`, but now no longer used:
- `Term::exponent_is_positive()`
- `Term::exponent_is_negative()`
- `Term::factor_and_is_not_one()`
- `Term::factor_as_u32()`

## [0.23.0] — 2024-05-30

### Added
Expand Down
37 changes: 37 additions & 0 deletions crates/api/src/annotation.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
use std::fmt;

use crate::Term;

#[derive(Default, Clone, Debug, PartialEq, Eq)]
pub struct Annotation(String);

impl Annotation {
pub(crate) const fn new(inner: String) -> Self {
Self(inner)
}

pub(crate) fn as_str(&self) -> &str {
&self.0
}
}

impl fmt::Display for Annotation {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{{{annotation}}}", annotation = self.0)
}
}

impl From<Annotation> for Term {
fn from(value: Annotation) -> Self {
Self::Annotation(value)
}
}

impl<'a, T> From<&'a T> for Annotation
where
T: ToString + ?Sized,
{
fn from(value: &'a T) -> Self {
Self(value.to_string())
}
}
Loading

0 comments on commit 39def96

Please sign in to comment.