当前位置: 首页 > news >正文

rust way step 1

install rust

CARGO_HOME  D:\rust\.cargo

RUSTUP_HOME D:\rust\.rustup

[dependencies] ferris-says = "0.2"

vscode 安装rust 插件  

use ferris_says::say; // from the previous step
use std::io::{stdout, BufWriter};fn main() {let stdout = stdout();let message = String::from("Hello fellow Rustaceans!");let width = message.chars().count();let mut writer = BufWriter::new(stdout.lock());say(message.as_bytes(), width, &mut writer).unwrap();
}

###############################

rust cargo镜像配置  config.toml

[source.crates-io]
replace-with = 'ustc'

[source.ustc]
registry = "git://mirrors.ustc.edu.cn/crates.io-index"
 

cargo install dioxus-cli
 

dx new
 

cd my_project
dx serve
 

realse

 cargo build --bin hellui --release

use dioxus::prelude::*;fn main() {launch(app);
}fn app() -> Element {rsx! {h1 { "Hello, Dioxus 0.5!" }h1 { "Hello, Dioxus 0.5!" }h1 { "Hello, Dioxus 0.5!" }div { "Hello, world!" }div { "Hello, world!" }div {class: "container",h1 {"标题",}p {style: "color: blue;","这是一行介绍,字体是蓝色的"}a {href: "https://dioxuslabs.com/","一个跳转到 Dioxus 官网的链接"}ul {li { "列表 - 1" }li { "列表 - 2" }li { "列表 - 3" }}}}
}
use dioxus::prelude::*;fn main() {LaunchBuilder::new().with_cfg(dioxus::desktop::Config::new().with_custom_index(r#"
<!DOCTYPE html>
<html><head><title>Dioxus app</title><meta name="viewport" content="width=device-width, initial-scale=1.0" /><style>body { background-color: olive; }</style></head><body><h1>External HTML</h1><div id="main">dfgdfg</div></body>
</html>"#.into(),),).launch(app);
}fn app() -> Element {rsx! {h1 { "Custom HTML!" }}
}
use dioxus::prelude::*;fn main() {launch(app);
}fn app() -> Element {// You can create as many eval instances as you wantlet mut eval = eval(r#"// You can send messages from JavaScript to Rust with the dioxus.send functiondioxus.send("Hi from JS!");// You can receive messages from Rust to JavaScript with the dioxus.recv functionlet msg = await dioxus.recv();console.log(msg);"#,);// You can send messages to JavaScript with the send methodeval.send("Hi from Rust1!".into()).unwrap();let future = use_resource(move || {to_owned![eval];async move {// You can receive any message from JavaScript with the recv methodeval.recv().await.unwrap()}});match future.read_unchecked().as_ref() {Some(v) => rsx! { p { "{v}" } },_ => rsx! { p { "hello" } },}
}
use dioxus::prelude::*;fn main() {launch(app);
}/* pub fn app() -> Element {rsx! {p {b { "Dioxus Labs" }" An Open Source project dedicated to making Rust UI wonderful."}button {// attributes / listeners// children"Hello, World!"}div { "Hello, world!" } p {b { "Dioxus Labs" }" An Open Source project dedicated to making Rust UI wonderful."}}
}
*/
/* 
pub fn app() -> Element {let mut name = use_signal(|| "bob".to_string());rsx! {input {// we tell the component what to rendervalue: "{name}",// and what to do when the value changesoninput: move |event| name.set(event.value())}}
}*/pub fn app() -> Element {rsx! {form { onsubmit: move |event| { println!("Submitted! {event:?}") },input { name: "name" }input { name: "age" }input { name: "date" }input { r#type: "submit" }}}
}

http://www.lryc.cn/news/397301.html

相关文章:

  • 视觉语言模型导论:这篇论文能成为你进军VLM的第一步
  • Postman工具基本使用
  • uni-app三部曲之三: 路由拦截
  • 专注于国产FPGA芯片研发的异格技术Pre-A+轮融资,博将控股再次投资
  • 【python】QWidget父子关系,控件显示优先级原理剖析与应用实战演练
  • CTF php RCE(三)
  • Android 注解的语法原理和使用方法
  • YOLOv10改进 | Conv篇 | 利用FasterBlock二次创新C2f提出一种全新的结构(全网独家首发,参数量下降70W)
  • 实验-ENSP实现防火墙区域策略与用户管理
  • 【游戏客户端】大话slg玩法架构(二)背景地图
  • git-工作场景
  • coco dataset标签数据结构(json文件)
  • GaussDB关键技术原理:高性能(四)
  • 总结之企业微信(一)——创建外部群二维码,用户扫码入群
  • 透视数据治理:企业如何衡量数据治理的效果?
  • ERC20查询操作--获取ERC20 Token的余额
  • Linux运维:MySQL中间件代理服务器,mycat读写分离应用实验
  • css文字自适应宽度动态出现省略号...
  • 边缘计算盒子_B100_Jetson Nano (aarch64)开发环境搭建
  • 【Superset】dashboard 自定义URL
  • 【Linux网络】IP协议{初识/报头/分片/网段划分/子网掩码/私网公网IP/认识网络世界/路由表}
  • 香蕉派BPI-Wifi6迷你路由器公开发售
  • WPF-控件样式设置
  • C++20中的指定初始化器(designated initializers)
  • QT跨平台开发(windows、mac)中.pro文件设置
  • wifi中的stream parser
  • GitHub网页打开慢的解决办法
  • 前端vue 实现取色板 的选择
  • [leetcode]partition-list 分隔链表
  • Apache功能配置:访问控制、日志分割; 部署AWStats日志分析工具