Skip to content

Commit 298641e

Browse files
committed
Update to rustc 0.13.0-nightly (39d740266 2015-01-01 15:51:08 +0000)
Main thing is unwrapping RWLock return values -- see: rust-lang/rust#19661 The other stuff is moving off deprecated iterator API to avoid warnings. TODO: we may need to pull kiss3d_recording out to a separate cargo project, since it appears Cargo can only produce one lib crate per project.
1 parent d6cc2f0 commit 298641e

File tree

8 files changed

+50
-46
lines changed

8 files changed

+50
-46
lines changed

examples/decomp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ fn main() {
9191
let mut part_faces = Vec::new();
9292

9393
for i in partitioning.into_iter() {
94-
part_faces.push(faces.read().data().as_ref().unwrap()[i]);
94+
part_faces.push(faces.read().unwrap().data().as_ref().unwrap()[i]);
9595
}
9696

9797
let faces = GPUVector::new(part_faces, BufferType::ElementArray, AllocationType::StaticDraw);

examples/relativity.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ fn main() {
6060
* Render
6161
*/
6262
while window.render_with_camera(&mut observer) {
63-
let mut c = context.write();
63+
let mut c = context.write().unwrap();
6464

6565
for event in window.events().iter() {
6666
match event.value {
@@ -275,7 +275,7 @@ impl Material for RelativisticMaterial {
275275
let ctxt = self.context.clone();
276276

277277
{
278-
let c = ctxt.read();
278+
let c = ctxt.read().unwrap();
279279
// XXX: this relative velocity est very wrong!
280280
self.rel_vel.upload(&c.speed_of_player);
281281
self.light_vel.upload(&c.speed_of_light);

src/loader/obj.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use std::io::Reader;
55
use std::str::Words;
66
use std::str::FromStr;
77
use std::io::IoResult;
8+
use std::iter::repeat;
89
use std::collections::HashMap;
910
use std::collections::hash_map::Entry;
1011
use std::sync::{Arc, RWLock};
@@ -361,7 +362,7 @@ fn reformat(coords: Vec<Coord>,
361362

362363
let resn = resn.unwrap_or_else(|| Mesh::compute_normals_array(resc.as_slice(), allfs.as_slice()));
363364
let resn = Arc::new(RWLock::new(GPUVector::new(resn, BufferType::Array, AllocationType::StaticDraw)));
364-
let resu = resu.unwrap_or_else(|| Vec::from_elem(resc.len(), na::orig()));
365+
let resu = resu.unwrap_or_else(|| repeat(na::orig()).take(resc.len()).collect());
365366
let resu = Arc::new(RWLock::new(GPUVector::new(resu, BufferType::Array, AllocationType::StaticDraw)));
366367
let resc = Arc::new(RWLock::new(GPUVector::new(resc, BufferType::Array, AllocationType::StaticDraw)));
367368

src/resource/mesh.rs

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use na;
77
use ncollide::procedural::{TriMesh, TriMesh3, IndexBuffer};
88
use resource::ShaderAttribute;
99
use resource::gpu_vector::{GPUVector, AllocationType, BufferType};
10+
use std::iter;
1011

1112
#[path = "../error.rs"]
1213
mod error;
@@ -38,7 +39,7 @@ impl Mesh {
3839

3940
let uvs = match uvs {
4041
Some(us) => us,
41-
None => Vec::from_elem(coords.len(), na::orig())
42+
None => iter::repeat(na::orig()).take(coords.len()).collect()
4243
};
4344

4445
let location = if dynamic_draw { AllocationType::DynamicDraw } else { AllocationType::StaticDraw };
@@ -65,32 +66,32 @@ impl Mesh {
6566

6667
/// Creates a triangle mesh from this mesh.
6768
pub fn to_trimesh(&self) -> Option<TriMesh3<GLfloat>> {
68-
let unload_coords = !self.coords.read().is_on_ram();
69-
let unload_faces = !self.faces.read().is_on_ram();
70-
let unload_normals = !self.normals.read().is_on_ram();
71-
let unload_uvs = !self.uvs.read().is_on_ram();
69+
let unload_coords = !self.coords.read().unwrap().is_on_ram();
70+
let unload_faces = !self.faces.read().unwrap().is_on_ram();
71+
let unload_normals = !self.normals.read().unwrap().is_on_ram();
72+
let unload_uvs = !self.uvs.read().unwrap().is_on_ram();
7273

73-
self.coords.write().load_to_ram();
74-
self.faces.write().load_to_ram();
75-
self.normals.write().load_to_ram();
76-
self.uvs.write().load_to_ram();
74+
self.coords.write().unwrap().load_to_ram();
75+
self.faces.write().unwrap().load_to_ram();
76+
self.normals.write().unwrap().load_to_ram();
77+
self.uvs.write().unwrap().load_to_ram();
7778

78-
let coords = self.coords.read().to_owned();
79-
let faces = self.faces.read().to_owned();
80-
let normals = self.normals.read().to_owned();
81-
let uvs = self.uvs.read().to_owned();
79+
let coords = self.coords.read().unwrap().to_owned();
80+
let faces = self.faces.read().unwrap().to_owned();
81+
let normals = self.normals.read().unwrap().to_owned();
82+
let uvs = self.uvs.read().unwrap().to_owned();
8283

8384
if unload_coords {
84-
self.coords.write().unload_from_ram();
85+
self.coords.write().unwrap().unload_from_ram();
8586
}
8687
if unload_faces {
87-
self.coords.write().unload_from_ram();
88+
self.coords.write().unwrap().unload_from_ram();
8889
}
8990
if unload_normals {
90-
self.coords.write().unload_from_ram();
91+
self.coords.write().unwrap().unload_from_ram();
9192
}
9293
if unload_uvs {
93-
self.coords.write().unload_from_ram();
94+
self.coords.write().unwrap().unload_from_ram();
9495
}
9596

9697
if coords.is_none() || faces.is_none() {
@@ -117,22 +118,22 @@ impl Mesh {
117118

118119
/// Binds this mesh vertex coordinates buffer to a vertex attribute.
119120
pub fn bind_coords(&mut self, coords: &mut ShaderAttribute<Pnt3<GLfloat>>) {
120-
coords.bind(self.coords.write().deref_mut());
121+
coords.bind(self.coords.write().unwrap().deref_mut());
121122
}
122123

123124
/// Binds this mesh vertex normals buffer to a vertex attribute.
124125
pub fn bind_normals(&mut self, normals: &mut ShaderAttribute<Vec3<GLfloat>>) {
125-
normals.bind(self.normals.write().deref_mut());
126+
normals.bind(self.normals.write().unwrap().deref_mut());
126127
}
127128

128129
/// Binds this mesh vertex uvs buffer to a vertex attribute.
129130
pub fn bind_uvs(&mut self, uvs: &mut ShaderAttribute<Pnt2<GLfloat>>) {
130-
uvs.bind(self.uvs.write().deref_mut());
131+
uvs.bind(self.uvs.write().unwrap().deref_mut());
131132
}
132133

133134
/// Binds this mesh vertex uvs buffer to a vertex attribute.
134135
pub fn bind_faces(&mut self) {
135-
self.faces.write().bind();
136+
self.faces.write().unwrap().bind();
136137
}
137138

138139
/// Binds this mesh buffers to vertex attributes.
@@ -148,22 +149,22 @@ impl Mesh {
148149

149150
/// Unbind this mesh buffers to vertex attributes.
150151
pub fn unbind(&self) {
151-
self.coords.write().unbind();
152-
self.normals.write().unbind();
153-
self.uvs.write().unbind();
154-
self.faces.write().unbind();
152+
self.coords.write().unwrap().unbind();
153+
self.normals.write().unwrap().unbind();
154+
self.uvs.write().unwrap().unbind();
155+
self.faces.write().unwrap().unbind();
155156
}
156157

157158
/// Number of points needed to draw this mesh.
158159
pub fn num_pts(&self) -> uint {
159-
self.faces.read().len() * 3
160+
self.faces.read().unwrap().len() * 3
160161
}
161162

162163
/// Recompute this mesh normals.
163164
pub fn recompute_normals(&mut self) {
164-
Mesh::compute_normals(self.coords.read().data().as_ref().unwrap().as_slice(),
165-
self.faces.read().data().as_ref().unwrap().as_slice(),
166-
self.normals.write().data_mut().as_mut().unwrap());
165+
Mesh::compute_normals(self.coords.read().unwrap().data().as_ref().unwrap().as_slice(),
166+
self.faces.read().unwrap().data().as_ref().unwrap().as_slice(),
167+
self.normals.write().unwrap().data_mut().as_mut().unwrap());
167168
}
168169

169170
/// This mesh faces.
@@ -199,10 +200,10 @@ impl Mesh {
199200
pub fn compute_normals(coordinates: &[Pnt3<GLfloat>],
200201
faces: &[Vec3<GLuint>],
201202
normals: &mut Vec<Vec3<GLfloat>>) {
202-
let mut divisor = Vec::from_elem(coordinates.len(), 0f32);
203+
let mut divisor:Vec<f32> = iter::repeat(0f32).take(coordinates.len()).collect();
203204

204205
normals.clear();
205-
normals.grow(coordinates.len(), na::zero());
206+
normals.extend(iter::repeat(na::zero()).take(coordinates.len()));
206207

207208
// Accumulate normals ...
208209
for f in faces.iter() {

src/resource/shader.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::mem;
22
use std::ptr;
33
use std::str;
4+
use std::iter::repeat;
45
use std::kinds::marker::NoCopy;
56
use std::io::fs::File;
67
use std::io::fs::PathExtensions;
@@ -203,7 +204,7 @@ fn check_shader_error(shader: GLuint) {
203204
if info_log_len > 0 {
204205
// error check for fail to allocate memory omitted
205206
let mut chars_written = 0;
206-
let info_log = " ".repeat(info_log_len as uint);
207+
let info_log: String = repeat(' ').take(info_log_len as uint).collect();
207208

208209
let mut c_str = info_log.to_c_str();
209210

src/scene/object.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -204,13 +204,13 @@ impl Object {
204204
/// Mutably access the object's vertices.
205205
#[inline(always)]
206206
pub fn modify_vertices(&mut self, f: &mut |&mut Vec<Pnt3<GLfloat>>| -> ()) {
207-
let _ = self.mesh.borrow_mut().coords().write().data_mut().as_mut().map(|coords| (*f)(coords));
207+
let _ = self.mesh.borrow_mut().coords().write().unwrap().data_mut().as_mut().map(|coords| (*f)(coords));
208208
}
209209

210210
/// Access the object's vertices.
211211
#[inline(always)]
212212
pub fn read_vertices(&self, f: &mut |&[Pnt3<GLfloat>]| -> ()) {
213-
let _ = self.mesh.borrow().coords().read().data().as_ref().map(|coords| (*f)(coords.as_slice()));
213+
let _ = self.mesh.borrow().coords().read().unwrap().data().as_ref().map(|coords| (*f)(coords.as_slice()));
214214
}
215215

216216
/// Recomputes the normals of this object's mesh.
@@ -222,37 +222,37 @@ impl Object {
222222
/// Mutably access the object's normals.
223223
#[inline(always)]
224224
pub fn modify_normals(&mut self, f: &mut |&mut Vec<Vec3<GLfloat>>| -> ()) {
225-
let _ = self.mesh.borrow_mut().normals().write().data_mut().as_mut().map(|normals| (*f)(normals));
225+
let _ = self.mesh.borrow_mut().normals().write().unwrap().data_mut().as_mut().map(|normals| (*f)(normals));
226226
}
227227

228228
/// Access the object's normals.
229229
#[inline(always)]
230230
pub fn read_normals(&self, f: &mut |&[Vec3<GLfloat>]| -> ()) {
231-
let _ = self.mesh.borrow().normals().read().data().as_ref().map(|normals| (*f)(normals.as_slice()));
231+
let _ = self.mesh.borrow().normals().read().unwrap().data().as_ref().map(|normals| (*f)(normals.as_slice()));
232232
}
233233

234234
/// Mutably access the object's faces.
235235
#[inline(always)]
236236
pub fn modify_faces(&mut self, f: &mut |&mut Vec<Vec3<GLuint>>| -> ()) {
237-
let _ = self.mesh.borrow_mut().faces().write().data_mut().as_mut().map(|faces| (*f)(faces));
237+
let _ = self.mesh.borrow_mut().faces().write().unwrap().data_mut().as_mut().map(|faces| (*f)(faces));
238238
}
239239

240240
/// Access the object's faces.
241241
#[inline(always)]
242242
pub fn read_faces(&self, f: &mut |&[Vec3<GLuint>]| -> ()) {
243-
let _ = self.mesh.borrow().faces().read().data().as_ref().map(|faces| (*f)(faces.as_slice()));
243+
let _ = self.mesh.borrow().faces().read().unwrap().data().as_ref().map(|faces| (*f)(faces.as_slice()));
244244
}
245245

246246
/// Mutably access the object's texture coordinates.
247247
#[inline(always)]
248248
pub fn modify_uvs(&mut self, f: &mut |&mut Vec<Pnt2<GLfloat>>| -> ()) {
249-
let _ = self.mesh.borrow_mut().uvs().write().data_mut().as_mut().map(|uvs| (*f)(uvs));
249+
let _ = self.mesh.borrow_mut().uvs().write().unwrap().data_mut().as_mut().map(|uvs| (*f)(uvs));
250250
}
251251

252252
/// Access the object's texture coordinates.
253253
#[inline(always)]
254254
pub fn read_uvs(&self, f: &mut |&[Pnt2<GLfloat>]| -> ()) {
255-
let _ = self.mesh.borrow().uvs().read().data().as_ref().map(|uvs| (*f)(uvs.as_slice()));
255+
let _ = self.mesh.borrow().uvs().read().unwrap().data().as_ref().map(|uvs| (*f)(uvs.as_slice()));
256256
}
257257

258258

src/text/font.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl Font {
4747
face: ptr::null_mut(),
4848
texture_atlas: 0,
4949
atlas_dimensions: na::zero(),
50-
glyphs: Vec::from_fn(128, |_| None),
50+
glyphs: range(0, 128).map(|_:int| None).collect(),
5151
height: 0,
5252
nocpy: NoCopy
5353
};

src/window/window.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use std::io::timer::Timer;
99
use std::cell::RefCell;
1010
use std::rc::Rc;
1111
use libc;
12+
use std::iter::repeat;
1213
use std::time::Duration;
1314
use time;
1415
use gl;
@@ -374,7 +375,7 @@ impl Window {
374375

375376
if out.len() < size {
376377
let diff = size - out.len();
377-
out.grow(diff, 0);
378+
out.extend(repeat(0).take(diff));
378379
}
379380
else {
380381
out.truncate(size)

0 commit comments

Comments
 (0)