当前位置: 首页 > 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" }}}
}

相关文章:

  • 北京网站建设多少钱?
  • 辽宁网页制作哪家好_网站建设
  • 高端品牌网站建设_汉中网站制作
  • 宏碁F5-572G-59K3笔记本笔记本电脑拆机清灰教程(详解)
  • 中职网络安全B模块渗透测试server2003
  • 解释如单例、工厂、观察者等常见设计模式在Android开发中的应用。
  • kali安装vulhub遇到的问题及解决方法(docker及docker镜像源更换)
  • 两段序列帧动画播放,在ios机型上出现闪屏
  • python的字符串
  • C++从入门到起飞之——缺省参数/函数重载/引用全方位剖析!
  • python为什么慢?(自用)
  • 软件建模概要
  • Vagrant配合VirtualBox搭建虚拟机
  • 设计模式8-桥模式
  • Windows之nslookup命令
  • 图解数据结构---绪论
  • # Redis 入门到精通(一)数据类型(4)
  • 创建yum源、NFS共享存储
  • 【前端学习】-粗谈选择器
  • 【译】理解JavaScript:new 关键字
  • github指令
  • Java|序列化异常StreamCorruptedException的解决方法
  • Js实现点击查看全文(类似今日头条、知乎日报效果)
  • LeetCode541. Reverse String II -- 按步长反转字符串
  • Linux学习笔记6-使用fdisk进行磁盘管理
  • PAT A1017 优先队列
  • PHP 程序员也能做的 Java 开发 30分钟使用 netty 轻松打造一个高性能 websocket 服务...
  • unity如何实现一个固定宽度的orthagraphic相机
  • vue2.0项目引入element-ui
  • 阿里云爬虫风险管理产品商业化,为云端流量保驾护航
  • 缓存与缓冲
  • 三分钟教你同步 Visual Studio Code 设置
  • 什么软件可以提取视频中的音频制作成手机铃声
  • 问题之ssh中Host key verification failed的解决
  • 学习笔记TF060:图像语音结合,看图说话
  • 一起参Ember.js讨论、问答社区。
  • # dbt source dbt source freshness命令详解
  • # windows 运行框输入mrt提示错误:Windows 找不到文件‘mrt‘。请确定文件名是否正确后,再试一次
  • ###项目技术发展史
  • #{}和${}的区别?
  • (0)Nginx 功能特性
  • (02)vite环境变量配置
  • (C语言)字符分类函数
  • (solr系列:一)使用tomcat部署solr服务
  • (保姆级教程)Mysql中索引、触发器、存储过程、存储函数的概念、作用,以及如何使用索引、存储过程,代码操作演示
  • (第27天)Oracle 数据泵转换分区表
  • (二十一)devops持续集成开发——使用jenkins的Docker Pipeline插件完成docker项目的pipeline流水线发布
  • (分布式缓存)Redis哨兵
  • (回溯) LeetCode 46. 全排列
  • (回溯) LeetCode 77. 组合
  • (论文阅读23/100)Hierarchical Convolutional Features for Visual Tracking
  • (原创)boost.property_tree解析xml的帮助类以及中文解析问题的解决
  • (转)人的集合论——移山之道
  • .apk文件,IIS不支持下载解决
  • .Mobi域名介绍
  • .Net MVC4 上传大文件,并保存表单
  • .Net mvc总结
  • .net 提取注释生成API文档 帮助文档