Skip to content

Commit 8f83ee1

Browse files
committed
Address clippy lints.
1 parent ebb5c91 commit 8f83ee1

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

playground/src/app/text_editor.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,19 @@
33
// https://github.com/broxamson/hcl-leptos-app/blob/6f2da694fb97e60f4d2fd7cc7038bfb483566ba3/src/pages/global_components/text_editor.rs
44
// https://github.com/siku2/rust-monaco/issues/50
55

6+
#[cfg(target_arch = "wasm32")]
67
use std::{cell::RefCell, rc::Rc};
78

89
use leptos::{
9-
component, create_node_ref, create_rw_signal, create_signal, html::Div, view, IntoView,
10-
NodeRef, ReadSignal, RwSignal, SignalGetUntracked, WriteSignal,
10+
component, create_node_ref, create_signal, html::Div, view, IntoView, NodeRef, ReadSignal,
11+
WriteSignal,
1112
};
13+
14+
#[cfg(target_arch = "wasm32")]
1215
use monaco::api::{CodeEditor, TextModel};
1316

1417
#[cfg(target_arch = "wasm32")]
15-
use leptos::{SignalGet, SignalSet, SignalUpdate};
18+
use leptos::{create_rw_signal, RwSignal, SignalGet, SignalGetUntracked, SignalSet, SignalUpdate};
1619
#[cfg(target_arch = "wasm32")]
1720
use monaco::{
1821
api::CodeEditorOptions,
@@ -111,12 +114,14 @@ pub fn TextEditor(
111114
}
112115

113116
/// Shared reference to the underlying [`CodeEditor`].
117+
#[cfg(target_arch = "wasm32")]
114118
pub type CodeEditorCell = Rc<RefCell<Option<CodeEditor>>>;
115119
#[cfg(target_arch = "wasm32")]
116120
pub type ClosureCell = Rc<RefCell<Option<(Closure<dyn Fn()>, IDisposable)>>>;
117121

118122
#[derive(Copy, Clone, Debug)]
119123
pub struct EditorState {
124+
#[cfg(target_arch = "wasm32")]
120125
pub code_editor: RwSignal<CodeEditorCell>,
121126
#[cfg(target_arch = "wasm32")]
122127
pub update_fn_closure: RwSignal<ClosureCell>,
@@ -131,12 +136,14 @@ impl Default for EditorState {
131136
impl EditorState {
132137
pub fn new() -> Self {
133138
Self {
139+
#[cfg(target_arch = "wasm32")]
134140
code_editor: create_rw_signal(CodeEditorCell::default()),
135141
#[cfg(target_arch = "wasm32")]
136142
update_fn_closure: create_rw_signal(ClosureCell::default()),
137143
}
138144
}
139145

146+
#[cfg(target_arch = "wasm32")]
140147
pub fn get_value(&self) -> String {
141148
self.code_editor
142149
.get_untracked()
@@ -148,6 +155,7 @@ impl EditorState {
148155
.unwrap_or_default()
149156
}
150157

158+
#[cfg(target_arch = "wasm32")]
151159
pub fn set_value(&self, value: &str) {
152160
if let Some(text_model) = self
153161
.code_editor

0 commit comments

Comments
 (0)