Skip to content

Commit 3e078d3

Browse files
authored
Merge pull request #62 from daschl/fix-rustc
Fix various rustc and clippy warnings.
2 parents 48622f2 + 7932abf commit 3e078d3

File tree

4 files changed

+32
-40
lines changed

4 files changed

+32
-40
lines changed

src/buffer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ impl<T: TensorType> Deref for Buffer<T> {
194194

195195
impl<T: TensorType> DerefMut for Buffer<T> {
196196
#[inline]
197-
fn deref_mut<'a>(&'a mut self) -> &'a mut [T] {
197+
fn deref_mut(&mut self) -> &mut [T] {
198198
self.as_mut()
199199
}
200200
}

src/graph.rs

+20-24
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
extern crate libc;
21
extern crate tensorflow_sys as tf;
32

43
use libc::c_float;
@@ -144,9 +143,9 @@ impl Graph {
144143
}
145144

146145
/// Iterates over the operations in the graph.
147-
pub fn operation_iter<'a>(&'a self) -> OperationIter<'a> {
146+
pub fn operation_iter(&self) -> OperationIter {
148147
OperationIter {
149-
graph: &self,
148+
graph: self,
150149
pos: 0,
151150
}
152151
}
@@ -492,9 +491,6 @@ impl<'a> Input<'a> {
492491

493492
////////////////////////
494493

495-
#[deprecated(note="Use Output instead.")]
496-
type Port<'a> = Output<'a>;
497-
498494
/// A `Output` is one end of a graph edge.
499495
/// It holds an operation and an index into the outputs of that operation.
500496
#[derive(Debug,Copy,Clone)]
@@ -756,13 +752,13 @@ impl<'a> OperationDescription<'a> {
756752
-> std::result::Result<(), NulError> {
757753
let c_attr_name = try!(CString::new(attr_name));
758754
unsafe {
759-
match &value.0 {
760-
&None => tf::TF_SetAttrShape(self.inner, c_attr_name.as_ptr(), ptr::null(), -1),
761-
&Some(ref dims) => {
755+
match value.0 {
756+
None => tf::TF_SetAttrShape(self.inner, c_attr_name.as_ptr(), ptr::null(), -1),
757+
Some(ref dims) => {
762758
let c_dims: Vec<i64> = dims.iter()
763-
.map(|x| match x {
764-
&Some(d) => d,
765-
&None => -1,
759+
.map(|x| match *x {
760+
Some(d) => d,
761+
None => -1,
766762
})
767763
.collect();
768764
tf::TF_SetAttrShape(self.inner,
@@ -783,28 +779,28 @@ impl<'a> OperationDescription<'a> {
783779
let c_attr_name = try!(CString::new(attr_name));
784780
// Convert Option<i64> in each shape to i64 with None becoming -1.
785781
let c_dims: Vec<Option<Vec<i64>>> = value.iter()
786-
.map(|x| match &x.0 {
787-
&None => None,
788-
&Some(ref dims) => {
782+
.map(|x| match x.0 {
783+
None => None,
784+
Some(ref dims) => {
789785
Some(dims.iter()
790-
.map(|x| match x {
791-
&None => -1,
792-
&Some(d) => d,
786+
.map(|x| match *x {
787+
None => -1,
788+
Some(d) => d,
793789
})
794790
.collect())
795791
}
796792
})
797793
.collect();
798794
let ptrs: Vec<*const i64> = c_dims.iter()
799-
.map(|x| match x {
800-
&None => ptr::null(),
801-
&Some(ref dims) => dims.as_ptr(),
795+
.map(|x| match *x {
796+
None => ptr::null(),
797+
Some(ref dims) => dims.as_ptr(),
802798
})
803799
.collect();
804800
let lens: Vec<c_int> = value.iter()
805-
.map(|x| match &x.0 {
806-
&None => -1,
807-
&Some(ref dims) => dims.len() as c_int,
801+
.map(|x| match x.0 {
802+
None => -1,
803+
Some(ref dims) => dims.len() as c_int,
808804
})
809805
.collect();
810806
unsafe {

src/lib.rs

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//! This crate provides Rust bindings for the
2-
//! [TensorFlow](https://www.tensorflow.org) machine learning library.
2+
//! [`TensorFlow`](https://www.tensorflow.org) machine learning library.
33
44
#![warn(missing_copy_implementations,
55
missing_debug_implementations,
@@ -343,6 +343,7 @@ c_enum!("Type of a single tensor element.", TF_DataType, DataType {
343343
/// 16-bit floating point.
344344
value Half = 19,
345345

346+
/// TensorFlow Resource (name, container, device,...)
346347
value Resource = 20,
347348
});
348349

@@ -936,7 +937,7 @@ impl<T: TensorType> Deref for Tensor<T> {
936937

937938
impl<T: TensorType> DerefMut for Tensor<T> {
938939
#[inline]
939-
fn deref_mut<'a>(&'a mut self) -> &'a mut [T] {
940+
fn deref_mut(&mut self) -> &mut [T] {
940941
&mut self.data
941942
}
942943
}
@@ -1010,7 +1011,7 @@ trait OperationTrait {
10101011
////////////////////////
10111012

10121013
/// Returns a string describing version information of the
1013-
/// TensorFlow library. TensorFlow using semantic versioning.
1014+
/// `TensorFlow` library. `TensorFlow` is using semantic versioning.
10141015
pub fn version() -> std::result::Result<String, Utf8Error> {
10151016
unsafe { CStr::from_ptr(tf::TF_Version()).to_str().map(|s| s.to_string()) }
10161017
}
@@ -1028,9 +1029,9 @@ pub struct Shape(Option<Vec<Option<i64>>>);
10281029
impl Shape {
10291030
/// Returns the number of dimensions if known, or None if unknown.
10301031
pub fn dims(&self) -> Option<usize> {
1031-
match self {
1032-
&Shape(None) => None,
1033-
&Shape(Some(ref v)) => Some(v.len()),
1032+
match *self {
1033+
Shape(None) => None,
1034+
Shape(Some(ref v)) => Some(v.len()),
10341035
}
10351036
}
10361037
}
@@ -1053,9 +1054,9 @@ impl Index<usize> for Shape {
10531054
type Output = Option<i64>;
10541055

10551056
fn index(&self, index: usize) -> &Option<i64> {
1056-
match &self.0 {
1057-
&None => &UNKNOWN_DIMENSION,
1058-
&Some(ref v) => {
1057+
match self.0 {
1058+
None => &UNKNOWN_DIMENSION,
1059+
Some(ref v) => {
10591060
if index < v.len() {
10601061
&v[index]
10611062
} else {

src/session.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
extern crate tensorflow_sys as tf;
2-
1+
use tf;
32
use libc::c_int;
43
use std::marker;
54
use std::ptr;
@@ -21,9 +20,6 @@ pub struct Session {
2120
inner: *mut tf::TF_Session,
2221
}
2322

24-
#[deprecated(note = "Use Session instead.")]
25-
type SessionWithGraph = Session;
26-
2723
impl Session {
2824
/// Creates a session.
2925
pub fn new(options: &SessionOptions, graph: &Graph) -> Result<Self> {
@@ -236,7 +232,6 @@ impl<'l> Drop for StepWithGraph<'l> {
236232

237233
#[cfg(test)]
238234
mod tests {
239-
extern crate tensorflow_sys as tf;
240235
use super::*;
241236
use super::super::DataType;
242237
use super::super::Graph;

0 commit comments

Comments
 (0)