@@ -17,11 +17,7 @@ use core::num::IntConvertible::from_int;
17
17
use core:: ptr:: to_mut_unsafe_ptr;
18
18
use core:: str:: as_c_str;
19
19
use core:: vec;
20
-
21
- #[ abi = "rust-intrinsic" ]
22
- extern mod rusti {
23
- fn init < T > ( ) -> T ;
24
- }
20
+ use core:: unstable:: intrinsics:: uninit;
25
21
26
22
struct mpz_struct {
27
23
_mp_alloc : c_int ,
@@ -159,15 +155,15 @@ impl Drop for Mpz {
159
155
impl Mpz {
160
156
fn new ( ) -> Mpz {
161
157
unsafe {
162
- let mut mpz = rusti :: init ( ) ; // TODO: switch to rusti::uninit when implemented
158
+ let mut mpz = uninit ( ) ;
163
159
__gmpz_init ( & mut mpz) ;
164
160
Mpz { mpz : mpz }
165
161
}
166
162
}
167
163
168
164
fn new_reserve ( n : c_ulong ) -> Mpz {
169
165
unsafe {
170
- let mut mpz = rusti :: init ( ) ; // TODO: switch to rusti::uninit when implemented
166
+ let mut mpz = uninit ( ) ;
171
167
__gmpz_init2 ( & mut mpz, n) ;
172
168
Mpz { mpz : mpz }
173
169
}
@@ -182,7 +178,7 @@ impl Mpz {
182
178
fn from_str_radix ( s : & str , base : uint ) -> Option < Mpz > {
183
179
unsafe {
184
180
assert ! ( base == 0 || ( base >= 2 && base <= 62 ) ) ;
185
- let mut mpz = rusti :: init ( ) ; // TODO: switch to rusti::uninit when implemented
181
+ let mut mpz = uninit ( ) ;
186
182
let mpz_ptr = to_mut_unsafe_ptr ( & mut mpz) ;
187
183
let r = as_c_str ( s, { |s| __gmpz_init_set_str ( mpz_ptr, s, base as c_int ) } ) ;
188
184
if r == 0 {
@@ -294,7 +290,7 @@ impl Mpz {
294
290
impl Clone for Mpz {
295
291
fn clone ( & self ) -> Mpz {
296
292
unsafe {
297
- let mut mpz = rusti :: init ( ) ; // TODO: switch to rusti::uninit when implemented
293
+ let mut mpz = uninit ( ) ;
298
294
__gmpz_init_set ( & mut mpz, & self . mpz ) ;
299
295
Mpz { mpz : mpz }
300
296
}
@@ -415,7 +411,7 @@ impl IntConvertible for Mpz {
415
411
impl One for Mpz {
416
412
fn one() -> Mpz {
417
413
unsafe {
418
- let mut mpz = rusti::init (); // TODO: switch to rusti::uninit when implemented
414
+ let mut mpz = uninit ();
419
415
__gmpz_init_set_ui(&mut mpz, 1);
420
416
Mpz { mpz: mpz }
421
417
}
@@ -502,35 +498,31 @@ impl Drop for RandState {
502
498
impl RandState {
503
499
fn new() -> RandState {
504
500
unsafe {
505
- // TODO: switch to rusti::uninit when implemented
506
- let mut state: gmp_randstate_struct = rusti::init();
501
+ let mut state: gmp_randstate_struct = uninit();
507
502
__gmp_randinit_default(&mut state);
508
503
RandState { state: state }
509
504
}
510
505
}
511
506
512
507
fn new_mt() -> RandState {
513
508
unsafe {
514
- // TODO: switch to rusti::uninit when implemented
515
- let mut state: gmp_randstate_struct = rusti::init();
509
+ let mut state: gmp_randstate_struct = uninit();
516
510
__gmp_randinit_mt(&mut state);
517
511
RandState { state: state }
518
512
}
519
513
}
520
514
521
515
fn new_lc_2exp(a: Mpz, c: c_ulong, m2exp: c_ulong) -> RandState {
522
516
unsafe {
523
- // TODO: switch to rusti::uninit when implemented
524
- let mut state: gmp_randstate_struct = rusti::init();
517
+ let mut state: gmp_randstate_struct = uninit();
525
518
__gmp_randinit_lc_2exp(&mut state, &a.mpz, c, m2exp);
526
519
RandState { state: state }
527
520
}
528
521
}
529
522
530
523
fn new_lc_2exp_size(size: c_ulong) -> RandState {
531
524
unsafe {
532
- // TODO: switch to rusti::uninit when implemented
533
- let mut state: gmp_randstate_struct = rusti::init();
525
+ let mut state: gmp_randstate_struct = uninit();
534
526
__gmp_randinit_lc_2exp_size(&mut state, size);
535
527
RandState { state: state }
536
528
}
@@ -566,8 +558,7 @@ impl RandState {
566
558
impl Clone for RandState {
567
559
fn clone(&self) -> RandState {
568
560
unsafe {
569
- // TODO: switch to rusti::uninit when implemented
570
- let mut state: gmp_randstate_struct = rusti::init();
561
+ let mut state: gmp_randstate_struct = uninit();
571
562
__gmp_randinit_set(&mut state, &self.state);
572
563
RandState { state: state }
573
564
}
@@ -586,7 +577,7 @@ impl Drop for Mpq {
586
577
impl Mpq {
587
578
fn new() -> Mpq {
588
579
unsafe {
589
- let mut mpq = rusti::init (); // TODO: switch to rusti::uninit when implemented
580
+ let mut mpq = uninit ();
590
581
__gmpq_init(&mut mpq);
591
582
Mpq { mpq: mpq }
592
583
}
@@ -768,7 +759,7 @@ impl Drop for Mpf {
768
759
impl Mpf {
769
760
fn new(precision: c_ulong) -> Mpf {
770
761
unsafe {
771
- let mut mpf = rusti::init (); // TODO: switch to rusti::uninit when implemented
762
+ let mut mpf = uninit ();
772
763
__gmpf_init2(&mut mpf, precision);
773
764
Mpf { mpf: mpf }
774
765
}
@@ -831,7 +822,7 @@ impl Mpf {
831
822
impl Clone for Mpf {
832
823
fn clone(&self) -> Mpf {
833
824
unsafe {
834
- let mut mpf = rusti::init (); // TODO: switch to rusti::uninit when implemented
825
+ let mut mpf = uninit ();
835
826
__gmpf_init_set(&mut mpf, &self.mpf);
836
827
Mpf { mpf: mpf }
837
828
}
0 commit comments