Skip to content

Commit 7702fb1

Browse files
committed
tweak: Small changes.
Remove `todo!` as it wants Rust 1.40.
1 parent 688f46f commit 7702fb1

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

examples/extension/src/extension.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,9 @@ use sciter::Value;
1010

1111
/// Extension entry point.
1212
#[no_mangle]
13-
pub extern "system"
14-
fn SciterLibraryInit(api: &'static sciter::ISciterAPI, exported: &mut VALUE) -> BOOL
15-
{
13+
pub extern "system" fn SciterLibraryInit(api: &'static sciter::ISciterAPI, exported: &mut VALUE) -> BOOL {
1614
sciter::set_host_api(api);
1715

18-
let _a = Value::from(add);
19-
let _b = Value::from(sub);
20-
2116
let ext_api = vmap! {
2217
"add" => add,
2318
"sub" => sub,
@@ -28,7 +23,6 @@ fn SciterLibraryInit(api: &'static sciter::ISciterAPI, exported: &mut VALUE) ->
2823
true as BOOL
2924
}
3025

31-
3226
/// Calculate the sum of all the given arguments.
3327
pub fn add(args: &[Value]) -> Value {
3428
let sum: i32 = args
@@ -38,15 +32,18 @@ pub fn add(args: &[Value]) -> Value {
3832
.map(|v| v.unwrap())
3933
.sum();
4034

41-
Value::from(sum)
35+
sum.into()
4236
}
4337

4438
/// `function sub(a, b) { return a - b; }`
4539
pub fn sub(args: &[Value]) -> std::result::Result<Value, String> {
4640
if let [a, b] = args {
4741
let a = a.to_int().ok_or("`a` is not an int")?;
4842
let b = b.to_int().ok_or("`b` is not an int")?;
49-
Ok(Value::from(a - b))
43+
44+
let result = a - b;
45+
46+
Ok(result.into())
5047
} else {
5148
Err(format!("sub(a,b) expects 2 parameters, given {} instead.", args.len()))
5249
}

src/capi/scdef.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,9 @@ pub type KeyValueCallback = extern "system" fn (param: LPVOID, pkey: *const VALU
370370
/// fn SciterLibraryInit(api: &'static sciter::ISciterAPI, exported: &mut VALUE) -> BOOL
371371
/// {
372372
/// sciter::set_host_api(api);
373-
/// todo!("export some extension functions");
373+
///
374+
/// unimplemented!("export some extension functions");
375+
///
374376
/// true as BOOL
375377
/// }
376378
/// ```

0 commit comments

Comments
 (0)