aboutsummaryrefslogtreecommitdiff
path: root/docs/dev/pages/issues
diff options
context:
space:
mode:
Diffstat (limited to 'docs/dev/pages/issues')
-rw-r--r--docs/dev/pages/issues/remove-r-print-macro.md12
-rw-r--r--docs/dev/pages/issues/the-shit-time.md10
2 files changed, 16 insertions, 6 deletions
diff --git a/docs/dev/pages/issues/remove-r-print-macro.md b/docs/dev/pages/issues/remove-r-print-macro.md
index 53fa086..96f99ef 100644
--- a/docs/dev/pages/issues/remove-r-print-macro.md
+++ b/docs/dev/pages/issues/remove-r-print-macro.md
@@ -20,7 +20,7 @@ macro_rules! my_println {
r_println!("Custom: {}", format!($($arg)*));
};
}
-
+
#[renderer]
fn render_something(_p: ResultSomething) {
// Although this function body has __renderer_inner_result injected,
@@ -34,7 +34,7 @@ fn render_something(_p: ResultSomething) {
my_println!("{}", box_val); // Compile error: cannot find __renderer_inner_result
}
```
-
+
## Deeper Issues
I have to admit, this is an early design flaw. After re-examining the code, I found the problem goes beyond "can't be wrapped".
@@ -58,11 +58,11 @@ fn render_something(prev: ResultSomething) -> RenderResult {
result.println(prev.to_string());
// or
write!(result, "{}", prev.to_string());
-
+
result // return here
}
```
-
+
Clear boundaries — the entire rendering process is confined within the function body decorated by `#[help]` or `#[renderer]`, without introducing extra out-of-scope dependencies. The trade-off is slightly more boilerplate compared to the original approach.
### Option 2: Resource Injection
@@ -73,11 +73,11 @@ fn render_something(prev: ResultSomething, result: &mut ResRenderResult) {
result.println(prev.to_string());
// or
write!(result, "{}", prev.to_string());
-
+
result // return here
}
```
-
+
More flexible, but blurs the boundary between logic functions like `#[chain]` and rendering functions like `#[help]`.
### Preferred Direction
diff --git a/docs/dev/pages/issues/the-shit-time.md b/docs/dev/pages/issues/the-shit-time.md
index f524f42..9d6c429 100644
--- a/docs/dev/pages/issues/the-shit-time.md
+++ b/docs/dev/pages/issues/the-shit-time.md
@@ -83,6 +83,16 @@ fn desc_add() -> String {
t!("cmd.add.desc")
}
+// Or
+
+#[completion(CMDAdd)]
+fn desc_add(_ctx: &ShellContext) -> Suggest {
+ // If using rust_i18n
+ suggest{
+ t!("cmd.add.desc")
+ }
+}
+
// Collected and generated by `gen_program!()`
// Generate something like get_dispatcher_desc(id: &ThisProgram) -> String
// Match the corresponding function using enum values inside ThisProgram