Merge pull request #61 from Eliah-Lakhin/native-call-context-improvements

Minor improvements for NativeCallContext introspection
This commit is contained in:
Stephen Chung 2021-01-03 11:14:56 +08:00 committed by GitHub
commit c98d0fff40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -224,7 +224,11 @@ impl AST {
/// Set the source.
#[inline(always)]
pub fn set_source<S: Into<ImmutableString>>(&mut self, source: Option<S>) {
self.source = source.map(|s| s.into())
self.source = source.map(|s| s.into());
if let Some(module) = Shared::get_mut(&mut self.functions) {
module.set_id(self.source.clone());
}
}
/// Get the statements.
#[cfg(not(feature = "internals"))]

View File

@ -251,8 +251,8 @@ impl Module {
self.id.as_ref().map(|s| s.as_str())
}
/// Get the ID of the [`Module`], if any.
pub(crate) fn id_raw(&self) -> &Option<ImmutableString> {
/// Get the ID of the [`Module`] as an [`ImmutableString`], if any.
pub fn id_raw(&self) -> &Option<ImmutableString> {
&self.id
}