Skip to content

與原文程式範例不相同 #45

@JuenTingShie

Description

@JuenTingShie

您好,先感謝翻譯讓我可以入門Rust!

首先因為學習到 Reference 這個章節,發現反思的範例是不會出現錯誤的(在 y 仍在有效範圍時建立 &x),所以去看了原文之後才發現是跟原文範例不一樣的:

此中文翻譯

let mut x = 5;
let y = &mut x;

*y += 1;

println!("{}", x);

原文

let mut s = String::from("hello");

let r1 = &mut s;
let r2 = &mut s;

println!("{}, {}", r1, r2);

想請問是否為誤植,以及是否有可能盡量與原文內容相近呢? 謝謝

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions