Skip to content

Commit

Permalink
rename fn and more comments on UB
Browse files Browse the repository at this point in the history
  • Loading branch information
tesuji committed Apr 28, 2024
1 parent 192cdf4 commit a2c95a8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion ibus-gokien/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ impl IBusGokienEngine {
self.core.clear();
}

fn assert_is_self<'a>(engine: *mut IBusEngine) -> &'a mut Self {
// call more than once in scope is UB.
unsafe fn assert_is_self<'a>(engine: *mut IBusEngine) -> &'a mut Self {
let gokien: *mut Self = engine.cast();
Self::is_self(gokien);
unsafe { &mut *gokien }
Expand Down
2 changes: 1 addition & 1 deletion ibus-gokien/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ fn prepare(ibus: bool) -> Bus {
info!(?bus);
bus.register_disconnected_signal();
let file_path = get_engine_xml_path();
let component = Component::new_from_file(&file_path);
let component = Component::from_file(&file_path);
let component_name = component.get_name();
info!(?component_name);

Expand Down
4 changes: 2 additions & 2 deletions ribus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ impl Factory {
pub struct Component(*mut c::IBusComponent);

impl Component {
pub fn new_from_file(path: &CStr) -> Self {
pub fn from_file(path: &CStr) -> Self {
unsafe {
let comp = c::ibus_component_new_from_file(path.as_ptr());
Self(comp)
Expand Down Expand Up @@ -188,7 +188,7 @@ impl Component {
}

// The recommended way to load engine description data is using
// `Component::new_from_file` to load a component file, which also includes
// `Component::from_file` to load a component file, which also includes
// engine description data.
#[repr(transparent)]
pub struct EngineDesc(*mut c::IBusEngineDesc);
Expand Down

0 comments on commit a2c95a8

Please sign in to comment.