Rust vs Go:常用语法对比(九)

这篇具有很好参考价值的文章主要介绍了Rust vs Go:常用语法对比(九)。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

Rust vs Go:常用语法对比(九),后端

题图来自 Golang vs Rust - The Race to Better and Ultimate Programming Language


161. Multiply all the elements of a list

Multiply all the elements of the list elements by a constant c

将list中的每个元素都乘以一个数

package main

import (
 "fmt"
)

func main() {
 const c = 5.5
 elements := []float64{24930}
 fmt.Println(elements)

 for i := range elements {
  elements[i] *= c
 }
 fmt.Println(elements)
}

[2 4 9 30]
[11 22 49.5 165]

fn main() {
    let elements: Vec<f32> = vec![2.03.54.0];
    let c = 2.0;

    let elements = elements.into_iter().map(|x| c * x).collect::<Vec<_>>();

    println!("{:?}", elements);
}

[4.0, 7.0, 8.0]


162. Execute procedures depending on options

execute bat if b is a program option and fox if f is a program option.

根据选项执行程序

package main

import (
 "flag"
 "fmt"
 "os"
)

func init() {
 // Just for testing in the Playground, let's simulate
 // the user called this program with command line
 // flags -f and -b
 os.Args = []string{"program""-f""-b"}
}

var b = flag.Bool("b"false"Do bat")
var f = flag.Bool("f"false"Do fox")

func main() {
 flag.Parse()
 if *b {
  bar()
 }
 if *f {
  fox()
 }
 fmt.Println("The end.")
}

func bar() {
 fmt.Println("BAR")
}

func fox() {
 fmt.Println("FOX")
}

BAR
FOX
The end.

if let Some(arg) = ::std::env::args().nth(1) {
    if &arg == "f" {
        fox();
    } else if &arg = "b" {
        bat();
    } else {
 eprintln!("invalid argument: {}", arg),
    }
else {
    eprintln!("missing argument");
}

or

if let Some(arg) = ::std::env::args().nth(1) {
    match arg.as_str() {
        "f" => fox(),
        "b" => box(),
        _ => eprintln!("invalid argument: {}", arg),
    };
else {
    eprintln!("missing argument");
}

163. Print list elements by group of 2

Print all the list elements, two by two, assuming list length is even.

两个一组打印数组元素

package main

import (
 "fmt"
)

func main() {
 list := []string{"a""b""c""d""e""f"}

 for i := 0; i+1 < len(list); i += 2 {
  fmt.Println(list[i], list[i+1])
 }
}

a b
c d
e f

fn main() {
    let list = [1,2,3,4,5,6];
    for pair in list.chunks(2) {
        println!("({}, {})", pair[0], pair[1]);
    }
}

(12)
(34)
(56)

164. Open URL in default browser

Open the URL s in the default browser. Set boolean b to indicate whether the operation was successful.

在默认浏览器中打开链接

import "github.com/skratchdot/open-golang/open"
b := open.Start(s) == nil

or

func openbrowser(url string) {
 var err error

 switch runtime.GOOS {
 case "linux":
  err = exec.Command("xdg-open", url).Start()
 case "windows":
  err = exec.Command("rundll32""url.dll,FileProtocolHandler", url).Start()
 case "darwin":
  err = exec.Command("open", url).Start()
 default:
  err = fmt.Errorf("unsupported platform")
 }
 if err != nil {
  log.Fatal(err)
 }

}

use webbrowser;
webbrowser::open(s).expect("failed to open URL");

165. Last element of list

Assign to variable x the last element of list items.

列表中的最后一个元素

package main

import (
 "fmt"
)

func main() {
 items := []string"what""a""mess" }
 
 x := items[len(items)-1]

 fmt.Println(x)
}

mess


fn main() {
    let items = vec![568, -20942];
    let x = items[items.len()-1];
    println!("{:?}", x);
}

42

or

fn main() {
    let items = [568, -20942];
    let x = items.last().unwrap();
    println!("{:?}", x);
}

42


166. Concatenate two lists

Create list ab containing all the elements of list a, followed by all elements of list b.

连接两个列表

package main

import (
 "fmt"
)

func main() {
 a := []string{"The ""quick "}
 b := []string{"brown ""fox "}

 ab := append(a, b...)

 fmt.Printf("%q", ab)
}

["The " "quick " "brown " "fox "]

or

package main

import (
 "fmt"
)

func main() {
 type T string

 a := []T{"The ""quick "}
 b := []T{"brown ""fox "}

 var ab []T
 ab = append(append(ab, a...), b...)

 fmt.Printf("%q", ab)
}

["The " "quick " "brown " "fox "]

or

package main

import (
 "fmt"
)

func main() {
 type T string

 a := []T{"The ""quick "}
 b := []T{"brown ""fox "}

 ab := make([]T, len(a)+len(b))
 copy(ab, a)
 copy(ab[len(a):], b)

 fmt.Printf("%q", ab)
}

["The " "quick " "brown " "fox "]


fn main() {
    let a = vec![12];
    let b = vec![34];
    let ab = [a, b].concat();
    println!("{:?}", ab);
}

[1, 2, 3, 4]


167. Trim prefix

Create string t consisting of string s with its prefix p removed (if s starts with p).

移除前缀

package main

import (
 "fmt"
 "strings"
)

func main() {
 s := "café-society"
 p := "café"

 t := strings.TrimPrefix(s, p)

 fmt.Println(t)
}

-society


fn main() {
    {
        let s = "pre_thing";
        let p = "pre_";
        let t = s.trim_start_matches(p);
        println!("{}", t);
    }
    {
        // Warning: trim_start_matches removes several leading occurrences of p, if present.
        let s = "pre_pre_thing";
        let p = "pre_";
        let t = s.trim_start_matches(p);
        println!("{}", t);
    }
}
thing
thing

or

fn main() {
    let s = "pre_pre_thing";
    let p = "pre_";

    let t = if s.starts_with(p) { &s[p.len()..] } else { s };
    println!("{}", t);
}

pre_thing

or

fn main() {
    {
        let s = "pre_thing";
        let p = "pre_";
        let t = s.strip_prefix(p).unwrap_or_else(|| s);
        println!("{}", t);
    }
    {
        // If prefix p is repeated in s, it is removed only once by strip_prefix
        let s = "pre_pre_thing";
        let p = "pre_";
        let t = s.strip_prefix(p).unwrap_or_else(|| s);
        println!("{}", t);
    }
}

thing
pre_thing

168. Trim suffix

Create string t consisting of string s with its suffix w removed (if s ends with w).

移除后缀

package main

import (
 "fmt"
 "strings"
)

func main() {
 s := "café-society"
 w := "society"

 t := strings.TrimSuffix(s, w)

 fmt.Println(t)
}

café-


fn main() {
    let s = "thing_suf";
    let w = "_suf";
    let t = s.trim_end_matches(w);
    println!("{}", t);

    let s = "thing";
    let w = "_suf";
    let t = s.trim_end_matches(w); // s does not end with w, it is left intact
    println!("{}", t);

    let s = "thing_suf_suf";
    let w = "_suf";
    let t = s.trim_end_matches(w); // removes several occurrences of w
    println!("{}", t);
}

thing
thing
thing

or

fn main() {
    let s = "thing_suf";
    let w = "_suf";
    let t = s.strip_suffix(w).unwrap_or(s);
    println!("{}", t);

    let s = "thing";
    let w = "_suf";
    let t = s.strip_suffix(w).unwrap_or(s); // s does not end with w, it is left intact
    println!("{}", t);

    let s = "thing_suf_suf";
    let w = "_suf";
    let t = s.strip_suffix(w).unwrap_or(s); // only 1 occurrence of w is removed
    println!("{}", t);
}

thing
thing
thing_suf

169. String length

Assign to integer n the number of characters of string s. Make sure that multibyte characters are properly handled. n can be different from the number of bytes of s.

字符串长度

package main

import "fmt"
import "unicode/utf8"

func main() {
 s := "Hello, 世界"
 n := utf8.RuneCountInString(s)

 fmt.Println(n)
}

9


fn main() {
    let s = "世界";

    let n = s.chars().count();

    println!("{} characters", n);
}

2 characters


170. Get map size

Set n to the number of elements stored in mymap.
This is not always equal to the map capacity.

获取map的大小

package main

import "fmt"

func main() {
 mymap := map[string]int{"a"1"b"2"c"3}
 n := len(mymap)
 fmt.Println(n)
}

3


use std::collections::HashMap;

fn main() {
    let mut mymap: HashMap<&stri32> = [("one"1), ("two"2)].iter().cloned().collect();
    mymap.insert("three"3);

    let n = mymap.len();

    println!("mymap has {:?} entries", n);
}

mymap has 3 entries


171. Add an element at the end of a list

Append element x to the list s.

在list尾部添加元素

package main

import "fmt"

func main() {
 s := []int{11235813}
 x := 21

 s = append(s, x)

 fmt.Println(s)
}

[1 1 2 3 5 8 13 21]


fn main() {
    let mut s = vec![123];
    let x = 99;

    s.push(x);

    println!("{:?}", s);
}

[1, 2, 3, 99]


172. Insert entry in map

Insert value v for key k in map m.

向map中写入元素

package main

import "fmt"

func main() {
 m := map[string]int{"one"1"two"2}
 k := "three"
 v := 3

 m[k] = v

 fmt.Println(m)
}

map[one:1 three:3 two:2]


use std::collections::HashMap;

fn main() {
    let mut m: HashMap<&stri32> = [("one"1), ("two"2)].iter().cloned().collect();

    let (k, v) = ("three"3);

    m.insert(k, v);

    println!("{:?}", m);
}

{"three": 3, "one": 1, "two": 2}


173. Format a number with grouped thousands

Number will be formatted with a comma separator between every group of thousands.

按千位格式化数字

package main

import (
 "fmt"

 "golang.org/x/text/language"
 "golang.org/x/text/message"
)

// The Playground doesn't work with import of external packages.
// However, you may copy this source and test it on your workstation.

func main() {
 p := message.NewPrinter(language.English)
 s := p.Sprintf("%d\n"1000)

 fmt.Println(s)
 // Output:
 // 1,000
}

1,000

or

package main

import (
 "fmt"
 "github.com/floscodes/golang-thousands"
 "strconv"
)

// The Playground takes more time when importing external packages.
// However, you may want to copy this source and test it on your workstation.

func main() {
 n := strconv.Itoa(23489)
 s := thousands.Separate(n, "en")

 fmt.Println(s)
 // Output:
 // 23,489
}

23,489


use separator::Separatable;
println!("{}"1000.separated_string());

174. Make HTTP POST request

Make a HTTP request with method POST to URL u

发起http POST请求

package main

import (
 "fmt"
 "io"
 "io/ioutil"
 "net"
 "net/http"
)

func main() {
 contentType := "text/plain"
 var body io.Reader
 u := "http://" + localhost + "/hello"

 response, err := http.Post(u, contentType, body)
 check(err)
 buffer, err := ioutil.ReadAll(response.Body)
 check(err)
 fmt.Println("POST response:", response.StatusCode, string(buffer))

 response, err = http.Get(u)
 check(err)
 buffer, err = ioutil.ReadAll(response.Body)
 check(err)
 fmt.Println("GET  response:", response.StatusCode, string(buffer))
}

const localhost = "127.0.0.1:3000"

func init() {
 http.HandleFunc("/hello", myHandler)
 startServer()
}

func myHandler(w http.ResponseWriter, r *http.Request) {
 if r.Method != "POST" {
  w.WriteHeader(http.StatusBadRequest)
  fmt.Fprintf(w, "Refusing request verb %q", r.Method)
  return
 }
 fmt.Fprintf(w, "Hello POST :)")
}

func startServer() {
 listener, err := net.Listen("tcp", localhost)
 check(err)

 go http.Serve(listener, nil)
}

func check(err error) {
 if err != nil {
  panic(err)
 }
}

POST response: 200 Hello Alice (POST)
GET  response: 400 Refusing request verb "GET"

or

package main

import (
 "fmt"
 "io/ioutil"
 "net"
 "net/http"
 "net/url"
)

func main() {
 formValues := url.Values{
  "who": []string{"Alice"},
 }
 u := "http://" + localhost + "/hello"

 response, err := http.PostForm(u, formValues)
 check(err)
 buffer, err := ioutil.ReadAll(response.Body)
 check(err)
 fmt.Println("POST response:", response.StatusCode, string(buffer))

 response, err = http.Get(u)
 check(err)
 buffer, err = ioutil.ReadAll(response.Body)
 check(err)
 fmt.Println("GET  response:", response.StatusCode, string(buffer))
}

const localhost = "127.0.0.1:3000"

func init() {
 http.HandleFunc("/hello", myHandler)
 startServer()
}

func myHandler(w http.ResponseWriter, r *http.Request) {
 if r.Method != "POST" {
  w.WriteHeader(http.StatusBadRequest)
  fmt.Fprintf(w, "Refusing request verb %q", r.Method)
  return
 }
 fmt.Fprintf(w, "Hello %s (POST)", r.FormValue("who"))
}

func startServer() {
 listener, err := net.Listen("tcp", localhost)
 check(err)

 go http.Serve(listener, nil)
}

func check(err error) {
 if err != nil {
  panic(err)
 }
}

[dependencies]
error-chain = "0.12.4"
reqwest = { version = "0.11.2", features = ["blocking"] }

use error_chain::error_chain;
use std::io::Read;
let client = reqwest::blocking::Client::new();
let mut response = client.post(u).body("abc").send()?;

175. Bytes to hex string

From array a of n bytes, build the equivalent hex string s of 2n digits. Each byte (256 possible values) is encoded as two hexadecimal characters (16 possible values per digit).

字节转十六进制字符串

package main

import (
 "encoding/hex"
 "fmt"
)

func main() {
 a := []byte("Hello")

 s := hex.EncodeToString(a)

 fmt.Println(s)
}

48656c6c6f


use core::fmt::Write;

fn main() -> core::fmt::Result {
    let a = vec![224127193];
    let n = a.len();
    
    let mut s = String::with_capacity(2 * n);
    for byte in a {
        write!(s, "{:02X}", byte)?;
    }
    
    dbg!(s);
    Ok(())
}

[src/main.rs:12] s = "16047FC1"


176. Hex string to byte array

From hex string s of 2n digits, build the equivalent array a of n bytes. Each pair of hexadecimal characters (16 possible values per digit) is decoded into one byte (256 possible values).

十六进制字符串转字节数组

package main

import (
 "encoding/hex"
 "fmt"
 "log"
)

func main() {
 s := "48656c6c6f"

 a, err := hex.DecodeString(s)
 if err != nil {
  log.Fatal(err)
 }

 fmt.Println(a)
 fmt.Println(string(a))
}

[72 101 108 108 111]
Hello

use hex::FromHex
let a: Vec<u8> = Vec::from_hex(s).expect("Invalid Hex String");

178. Check if point is inside rectangle

Set boolean b to true if if the point with coordinates (x,y) is inside the rectangle with coordinates (x1,y1,x2,y2) , or to false otherwise. Describe if the edges are considered to be inside the rectangle.

检查点是否在矩形内

package main

import (
 "fmt"
 "image"
)

func main() {
 x1, y1, x2, y2 := 1150100
 r := image.Rect(x1, y1, x2, y2)

 x, y := 1010
 p := image.Pt(x, y)
 b := p.In(r)
 fmt.Println(b)

 x, y = 100100
 p = image.Pt(x, y)
 b = p.In(r)
 fmt.Println(b)
}

true
false

struct Rect {
    x1: i32,
    x2: i32,
    y1: i32,
    y2: i32,
}

impl Rect {
    fn contains(&self, x: i32, y: i32) -> bool {
        return self.x1 < x && x < self.x2 && self.y1 < y && y < self.y2;
    }
}

179. Get center of a rectangle

Return the center c of the rectangle with coördinates(x1,y1,x2,y2)

获取矩形的中心

import "image"
c := image.Pt((x1+x2)/2, (y1+y2)/2)

struct Rectangle {
    x1: f64,
    y1: f64,
    x2: f64,
    y2: f64,
}

impl Rectangle {
    pub fn center(&self) -> (f64f64) {
     ((self.x1 + self.x2) / 2.0, (self.y1 + self.y2) / 2.0)
    }
}

fn main() {
    let r = Rectangle {
        x1: 5.,
        y1: 5.,
        x2: 10.,
        y2: 10.,
    };
    
    println!("{:?}", r.center());
}

(7.5, 7.5)


180. List files in directory

Create list x containing the contents of directory d.
x may contain files and subfolders.
No recursive subfolder listing.

列出目录中的文件

package main

import (
 "fmt"
 "io/ioutil"
 "log"
)

func main() {
 d := "/"

 x, err := ioutil.ReadDir(d)
 if err != nil {
  log.Fatal(err)
 }

 for _, f := range x {
  fmt.Println(f.Name())
 }
}

.dockerenv
bin
dev
etc
home
lib
lib64
proc
root
sys
tmp
tmpfs
usr
var

use std::fs;

fn main() {
    let d = "/etc";

    let x = fs::read_dir(d).unwrap();

    for entry in x {
        let entry = entry.unwrap();
        println!("{:?}", entry.path());
    }
}

or

fn main() {
    let d = "/etc";

    let x = std::fs::read_dir(d)
        .unwrap()
        .collect::<Result<Vec<_>, _>>()
        .unwrap();

    for entry in x {
        println!("{:?}", entry.path());
    }
}
"/etc/issue.net"
"/etc/bindresvport.blacklist"
"/etc/rc1.d"
"/etc/hostname"
"/etc/xattr.conf"
"/etc/resolv.conf"
"/etc/pam.conf"
"/etc/mke2fs.conf"
"/etc/e2scrub.conf"
"/etc/update-motd.d"
"/etc/terminfo"
"/etc/alternatives"
"/etc/ld.so.cache"
"/etc/networks"
"/etc/profile"
"/etc/debconf.conf"
"/etc/security"
"/etc/.pwd.lock"
"/etc/gai.conf"
"/etc/dpkg"
"/etc/rc3.d"
"/etc/fstab"
"/etc/gshadow"
"/etc/sysctl.conf"
"/etc/rc2.d"
"/etc/selinux"
"/etc/ld.so.conf.d"
"/etc/os-release"
"/etc/libaudit.conf"
"/etc/login.defs"
"/etc/skel"
"/etc/shells"
"/etc/rc4.d"
"/etc/cron.d"
"/etc/default"
"/etc/lsb-release"
"/etc/apt"
"/etc/debian_version"
"/etc/machine-id"
"/etc/deluser.conf"
"/etc/group"
"/etc/legal"
"/etc/rc6.d"
"/etc/init.d"
"/etc/sysctl.d"
"/etc/pam.d"
"/etc/passwd"
"/etc/rc5.d"
"/etc/bash.bashrc"
"/etc/hosts"
"/etc/rc0.d"
"/etc/environment"
"/etc/cron.daily"
"/etc/shadow"
"/etc/ld.so.conf"
"/etc/subgid"
"/etc/opt"
"/etc/logrotate.d"
"/etc/subuid"
"/etc/profile.d"
"/etc/adduser.conf"
"/etc/issue"
"/etc/rmt"
"/etc/host.conf"
"/etc/rcS.d"
"/etc/nsswitch.conf"
"/etc/systemd"
"/etc/kernel"
"/etc/mtab"
"/etc/shadow-"
"/etc/passwd-"
"/etc/subuid-"
"/etc/gshadow-"
"/etc/subgid-"
"/etc/group-"
"/etc/ethertypes"
"/etc/logcheck"
"/etc/gss"
"/etc/bash_completion.d"
"/etc/X11"
"/etc/perl"
"/etc/ca-certificates"
"/etc/protocols"
"/etc/ca-certificates.conf"
"/etc/python2.7"
"/etc/localtime"
"/etc/xdg"
"/etc/timezone"
"/etc/mailcap.order"
"/etc/emacs"
"/etc/ssh"
"/etc/magic.mime"
"/etc/services"
"/etc/ssl"
"/etc/ldap"
"/etc/rpc"
"/etc/mime.types"
"/etc/magic"
"/etc/mailcap"
"/etc/inputrc"

本文由 mdnice 多平台发布文章来源地址https://www.toymoban.com/news/detail-610374.html

到了这里,关于Rust vs Go:常用语法对比(九)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • Rust vs Go:常用语法对比(七)

    题图来自 Go vs Rust: Which will be the top pick in programming? [1] 121. UDP listen and read Listen UDP traffic on port p and read 1024 bytes into buffer b. 听端口p上的UDP流量,并将1024字节读入缓冲区b。 122. Declare enumeration Create an enumerated type Suit with 4 possible values SPADES, HEARTS, DIAMONDS, CLUBS. 声明枚举值 Hearts

    2024年02月15日
    浏览(33)
  • Rust vs Go:常用语法对比(四)

    题图来自 Go vs. Rust performance comparison: The basics 61. Get current date 获取当前时间 Now is 2009-11-10 23:00:00 +0000 UTC m=+0.000000001 or SystemTime { tv_sec: 1526318418, tv_nsec: 699329521 } 62. Find substring position 字符串查找 查找子字符串位置 i is the byte index of y in x, not the character (rune) index. i will be -1 if y i

    2024年02月16日
    浏览(31)
  • Rust vs Go:常用语法对比(十一)

    题目来自 Rust Vs Go: Which Language Is Better For Developing High-Performance Applications? [1] 202. Sum of squares Calculate the sum of squares s of data, an array of floating point values. 计算平方和 +1.094200e+000 32.25 205. Get an environment variable Read an environment variable with the name \\\"FOO\\\" and assign it to the string variable foo. If i

    2024年02月15日
    浏览(29)
  • Rust vs Go:常用语法对比(八)

    题目来自 Golang vs. Rust: Which Programming Language To Choose in 2023? [1] 141. Iterate in sequence over two lists Iterate in sequence over the elements of the list items1 then items2. For each iteration print the element. 依次迭代两个列表 依次迭代列表项1和项2的元素。每次迭代打印元素。 1 2 3 a b c 142. Hexadecimal digits of

    2024年02月15日
    浏览(28)
  • Rust vs Go:常用语法对比(十二)

    题图来自 Rust vs Go in 2023 [1] 221. Remove all non-digits characters Create string t from string s, keeping only digit characters 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. 删除所有非数字字符 168 [src/main.rs:7] t = \\\"14\\\" 222. Find first index of an element in list Set i to the first index in list items at which the element x can be found, or -1 if items doe

    2024年02月15日
    浏览(39)
  • Rust vs Go:常用语法对比(二)

    21. Swap values 交换变量a和b的值 输出 a: 10, b: 3 or 输出 22. Convert string to integer 将字符串转换为整型 or 输出 or 输出 or 输出 23. Convert real number to string with 2 decimal places Given a real number x, create its string representation s with 2 decimal digits following the dot. 给定一个实数,小数点后保留两位小数

    2024年02月16日
    浏览(34)
  • Rust vs Go:常用语法对比(十三)

    题图来自 Go vs. Rust: The Ultimate Performance Battle 241. Yield priority to other threads Explicitly decrease the priority of the current process, so that other execution threads have a better chance to execute now. Then resume normal execution and call function busywork . 将优先权让给其他线程 After Gosched, the execution of the current gorout

    2024年02月15日
    浏览(30)
  • Java VS Go 还在纠结怎么选吗,(资深后端4000字带你深度对比)

    今天我们来聊一下Go 和Java,本篇文章主要是想给对后台开发的初学者和有意向选择Go语言的有经验的程序员一些建议,希望能帮助各位自上而下的来了解一下Java和Go的全貌。 作为一个多年的Java后端开发,用的时间久了就会发现Java语言一些问题,所谓婚前风花雪月,婚后柴米

    2024年02月04日
    浏览(29)
  • 【字节跳动青训营】后端笔记整理-1 | Go语言入门指南:基础语法和常用特性解析

    **本人是第六届字节跳动青训营(后端组)的成员。本文由博主本人整理自该营的日常学习实践,首发于稀土掘金:🔗Go语言入门指南:基础语法和常用特性解析 | 青训营 本文主要梳理自 第六届字节跳动青训营(后端组)-Go语言原理与实践第一节(王克纯老师主讲) 。同时

    2024年02月13日
    浏览(43)
  • 【Rust日报】2023-02-14 Rust GUI 框架对比: Tauri vs Iced vs egui

    Rust GUI 框架对比: Tauri vs Iced vs egui Tauri:使用系统的 webview 来渲染 HTML/JS 的前端。你可以选择任何前端框架。后台是用Rust编写的,可以通过内置的方法与前台通信。 Iced: 受 Elm 启发的(响应式)GUI库。在桌面上使用 wgpu 进行渲染;实验性的web后端创建DOM进行渲染。所有代码

    2024年02月02日
    浏览(27)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包