Skip to content

Commit

Permalink
Add documentation for type conversion functions
Browse files Browse the repository at this point in the history
Ref. eng/recordflux/RecordFlux!1685
  • Loading branch information
treiher committed Oct 21, 2024
1 parent 4e67acf commit bd21c3d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion librapidflux/src/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ pub enum Ty {
}

impl Ty {
/// Check compatibility to another type.
/// Check if all values of `other` are compatible with `self`.
///
/// A type is compatible if all values of `other` can be implicitly converted to a value of
/// `self`. All integer types are considered to be compatible with each other. This semantics is
/// used during model verification.
///
/// # Panics
///
Expand Down Expand Up @@ -93,6 +97,11 @@ impl Ty {
}
}

/// Check if all values of `other` are strongly compatible with `self`.
///
/// Different integer types are not considered to be compatible with each other. This semantics
/// is the same as in Ada/SPARK and is used to determine the need for explicit type conversions
/// during code generation.
pub fn is_compatible_strong(&self, other: &Ty) -> bool {
match (self, other) {
(Ty::Integer(integer), Ty::UniversalInteger(universal_integer))
Expand Down

0 comments on commit bd21c3d

Please sign in to comment.