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

rust: Inline Rust-specific one-line actions #1334

Merged
merged 1 commit into from
Dec 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
27 changes: 0 additions & 27 deletions lang/rust/rust.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,6 @@ class Actions:
def code_state_implements():
"""Inserts implements block, positioning the cursor appropriately"""

def code_insert_if_let_some():
"""Inserts if let some block, positioning the cursor appropriately"""

def code_insert_if_let_error():
"""Inserts if let error block, positioning the cursor appropriately"""

def code_insert_trait_annotation(type: str):
"""Inserts type annotation for implementor of trait"""

def code_insert_return_trait(type: str):
"""Inserts a return type for implementor of trait"""

def code_insert_macro(text: str, selection: str):
"""Inserts a macro and positions the cursor appropriately"""

Expand Down Expand Up @@ -479,15 +467,6 @@ def code_operator_increment():
def code_operator_structure_dereference():
actions.auto_insert("*")

def code_insert_if_let_some():
actions.user.insert_between("if let Some(", ")")

def code_insert_if_let_okay():
actions.user.insert_between("if let Ok(", ")")

def code_insert_if_let_error():
actions.user.insert_between("if let Err(", ")")

def code_state_implements():
actions.auto_insert("impl {}")
actions.edit.left()
Expand All @@ -496,12 +475,6 @@ def code_state_implements():
actions.edit.line_end()
repeat_call(2, actions.edit.left)

def code_insert_trait_annotation(type: str):
actions.auto_insert(f": impl {type}")

def code_insert_return_trait(type: str):
actions.auto_insert(f" -> impl {type}")

def code_insert_macro(text: str, selection: str):
if text in all_array_macro_values:
code_insert_function_or_macro(text, selection, "[", "]")
Expand Down
10 changes: 5 additions & 5 deletions lang/rust/rust.talon
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ use <user.code_libraries>:
key(; enter)

## specialist flow control
state if let some: user.code_insert_if_let_some()
state if let (ok | okay): user.code_insert_if_let_okay()
state if let error: user.code_insert_if_let_error()
state if let some: user.insert_between("if let Some(", ")")
state if let (ok | okay): user.insert_between("if let Ok(", ")")
state if let error: user.insert_between("if let Err(", ")")

## rust centric synonyms
is some: user.code_insert_is_not_null()
Expand All @@ -84,9 +84,9 @@ is some: user.code_insert_is_not_null()
implement (struct | structure): user.code_state_implements()

## for annotating function parameters
is implemented trait {user.code_trait}: user.code_insert_trait_annotation(code_trait)
is implemented trait {user.code_trait}: ": impl {code_trait}"
is implemented trait: ": impl "
returns implemented trait {user.code_trait}: user.code_insert_return_trait(code_trait)
returns implemented trait {user.code_trait}: " -> impl {code_trait}"
returns implemented trait: " -> impl "

## for generic reference of traits
Expand Down