Questions tagged «mutable»

可变项可以在创建后进行修改。



5
可从闭包访问可变变量。我怎样才能解决这个问题?
我正在使用Twitter的Typeahead。我正在从Intellij遇到此警告。这导致每个链接的“ window.location.href”成为我的项目列表中的最后一个项目。 如何修复我的代码? 下面是我的代码: AutoSuggest.prototype.config = function () { var me = this; var comp, options; var gotoUrl = "/{0}/{1}"; var imgurl = '<img src="/icon/{0}.gif"/>'; var target; for (var i = 0; i < me.targets.length; i++) { target = me.targets[i]; if ($("#" + target.inputId).length != 0) { options = { …

2
如何从方法中改变结构的字段?
我想做这个: struct Point { x: i32, y: i32, } impl Point { fn up(&self) { self.y += 1; } } fn main() { let p = Point { x: 0, y: 0 }; p.up(); } 但是这段代码会引发编译器错误: error[E0594]: cannot assign to field `self.y` of immutable binding --> src/main.rs:8:9 | 7 | …
73 rust  mutable 
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.