Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ty: Make type fields public #176

Merged
merged 7 commits into from
Mar 29, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
portable: Expose types as mutable from the PortableRegistry
Signed-off-by: Alexandru Vasile <[email protected]>
  • Loading branch information
lexnv committed Mar 28, 2023
commit 5dc4b8330b68aad315126e76deae6274b5d952b8
10 changes: 10 additions & 0 deletions src/portable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ impl PortableRegistry {
self.types.get(id as usize).map(|ty| ty.ty())
}

/// Returns the mutable type definition for the given identifier, `None` if no type found for that ID.
pub fn resolve_mut(&mut self, id: u32) -> Option<&mut Type<PortableForm>> {
self.types.get_mut(id as usize).map(|ty| ty.ty_mut())
}

/// Returns all types with their associated identifiers.
pub fn types(&self) -> &[PortableType] {
&self.types
Expand Down Expand Up @@ -256,6 +261,11 @@ impl PortableType {
pub fn ty(&self) -> &Type<PortableForm> {
&self.ty
}

/// Returns the mutable type of the [`PortableType`].
pub fn ty_mut(&mut self) -> &mut Type<PortableForm> {
&mut self.ty
}
}

/// Construct a [`PortableRegistry`].
Expand Down