Skip to content

Commit 7e908af

Browse files
committed
janitor: interpreter: Polish the highlight feature code
1 parent 67200c8 commit 7e908af

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

internal/interpreter/api.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -928,21 +928,23 @@ impl ComponentDefinition {
928928
self.inner.unerase(guard).type_loader.get().unwrap().clone()
929929
}
930930

931-
/// Return the `TypeLoader` used when parsing the code in the interpreter.
931+
/// Return the `TypeLoader` used when parsing the code in the interpreter in
932+
/// a state before most passes were applied by the compiler.
933+
///
934+
/// Each returned type loader is a deep copy of the entire state connected to it,
935+
/// so this is a fairly expensive function!
932936
///
933937
/// WARNING: this is not part of the public API
934938
#[cfg(feature = "highlight")]
935939
pub fn raw_type_loader(&self) -> Option<i_slint_compiler::typeloader::TypeLoader> {
936-
use i_slint_compiler::typeloader;
937-
938940
let guard = unsafe { generativity::Guard::new(generativity::Id::new()) };
939941
self.inner
940942
.unerase(guard)
941943
.raw_type_loader
942944
.get()
943945
.unwrap()
944946
.as_ref()
945-
.map(|tl| typeloader::snapshot(tl).unwrap())
947+
.and_then(|tl| i_slint_compiler::typeloader::snapshot(tl))
946948
}
947949
}
948950

0 commit comments

Comments
 (0)