Merge pull request #5 from peterwilli/no-std-compat

This commit is contained in:
Armin Becher 2021-08-19 15:19:08 +02:00 committed by GitHub
commit ddc7ae5501
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View file

@ -22,6 +22,13 @@ status = "actively-developed"
criterion = "0.3.1" criterion = "0.3.1"
rand="0.7.3" rand="0.7.3"
[dependencies]
no-std-compat = { version = "0.4.1", features = [ "alloc" ] }
[[bench]] [[bench]]
name = "benches" name = "benches"
harness = false harness = false
[features]
default = [ "std" ] # Default to using the std
std = [ "no-std-compat/std" ]

View file

@ -30,6 +30,14 @@ grid.push_row(vec![7,8,9]);
assert_eq!(grid, grid![[1,2,3][4,5,6][7,8,9]]) assert_eq!(grid, grid![[1,2,3][4,5,6][7,8,9]])
``` ```
*/ */
#![cfg_attr(not(feature = "std"), no_std)]
#[cfg(not(feature = "std"))]
extern crate no_std_compat as std;
#[cfg(not(feature = "std"))]
use std::prelude::v1::*;
use std::cmp::Eq; use std::cmp::Eq;
use std::fmt; use std::fmt;
use std::iter::StepBy; use std::iter::StepBy;
@ -539,7 +547,6 @@ impl<T: Clone> Grid<T> {
let mut col = Vec::with_capacity(self.rows); let mut col = Vec::with_capacity(self.rows);
for i in 0..self.rows { for i in 0..self.rows {
let idx = i * self.cols + self.cols - 1 - i; let idx = i * self.cols + self.cols - 1 - i;
println!["{:?}", idx];
col.push(self.data.remove(idx)); col.push(self.data.remove(idx));
} }
self.cols -= 1; self.cols -= 1;