Skip to content

Commit 1349c78

Browse files
committed
fix(doit): remove BorrowMut until it's cleared
See stackoverflow at http://goo.gl/f27zJkj. Now we can actually call out client and move on with handling the result
1 parent 9a58b0b commit 1349c78

4 files changed

Lines changed: 9 additions & 37 deletions

File tree

src/mako/lib.rs.mako

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<%
77
from util import (new_context, rust_comment, rust_doc_comment,
88
rust_module_doc_comment, rb_type, hub_type, mangle_ident, hub_type_params_s,
9-
hub_type_bounds, rb_type_params_s, find_fattest_resource)
9+
hub_type_bounds, rb_type_params_s, find_fattest_resource, HUB_TYPE_PARAMETERS)
1010
1111
c = new_context(schemas, resources)
1212
hub_type = hub_type(c.schemas, util.canonical_name())
@@ -19,9 +19,9 @@
1919
<%block filter="rust_module_doc_comment">\
2020
${lib.docs(c)}
2121
</%block>
22-
#![feature(core,io)]
22+
#![feature(core,io, old_io)]
2323
// DEBUG !! TODO: Remove this
24-
#![allow(dead_code)]
24+
#![allow(dead_code, deprecated)]
2525
// We don't warn about this, as depending on the API, some data structures or facilities are never used.
2626
// Instead of pre-determining this, we just disable the lint. It's manually tuned to not have any
2727
// unused imports in fully featured APIs. Same with unused_mut ... .
@@ -37,8 +37,6 @@ extern crate url;
3737
pub mod cmn;
3838

3939
use std::collections::HashMap;
40-
use std::marker::PhantomData;
41-
use std::borrow::BorrowMut;
4240
use std::cell::RefCell;
4341
use std::default::Default;
4442
use std::collections::BTreeMap;
@@ -84,21 +82,19 @@ ${lib.scope_enum()}
8482
${lib.hub_usage_example(c)}\
8583
</%block>
8684
pub struct ${hub_type}${ht_params} {
87-
client: RefCell<C>,
85+
client: RefCell<hyper::Client<NC>>,
8886
auth: RefCell<A>,
89-
_m: PhantomData<NC>
9087
}
9188

92-
impl<'a, C, NC, A> Hub for ${hub_type}${ht_params} {}
89+
impl<'a, ${', '.join(HUB_TYPE_PARAMETERS)}> Hub for ${hub_type}${ht_params} {}
9390

94-
impl<'a, C, NC, A> ${hub_type}${ht_params}
91+
impl<'a, ${', '.join(HUB_TYPE_PARAMETERS)}> ${hub_type}${ht_params}
9592
where ${', '.join(hub_type_bounds())} {
9693

97-
pub fn new(client: C, authenticator: A) -> ${hub_type}${ht_params} {
94+
pub fn new(client: hyper::Client<NC>, authenticator: A) -> ${hub_type}${ht_params} {
9895
${hub_type} {
9996
client: RefCell::new(client),
10097
auth: RefCell::new(authenticator),
101-
_m: PhantomData,
10298
}
10399
}
104100

src/mako/lib/mbuild.mako

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ ${self.usage(resource, method, m, params, request_value, parts)}\
8080
</%block>
8181
pub struct ${ThisType}
8282
where NC: 'a,
83-
C: 'a,
8483
A: 'a, {
8584
8685
hub: &'a ${hub_type_name}${hub_type_params_s()},
@@ -430,7 +429,7 @@ else {
430429
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));
431430
432431
loop {
433-
match self.hub.client.borrow_mut().borrow_mut().request(Method::Extension("${m.httpMethod}".to_string()), &url)
432+
match self.hub.client.borrow_mut().request(Method::Extension("${m.httpMethod}".to_string()), url.as_slice())
434433
.header(UserAgent("google-api-rust-client/${cargo.build_version}".to_string()))
435434
% if request_value:
436435
.header(ContentType(Mime(TopLevel::Application, SubLevel::Json, Default::default())))
@@ -457,33 +456,12 @@ else {
457456
}
458457
}
459458
460-
461459
% if response_schema:
462460
let response: ${response_schema.id} = Default::default();
463461
% else:
464462
let response = ();
465463
% endif
466464
467-
468-
## let mut params: Vec<(String, String)> = Vec::with_capacity
469-
## // note: cloned() shouldn't be needed, see issue
470-
## // https://github.com/servo/rust-url/issues/81
471-
## let req = form_urlencoded::serialize(
472-
## [("client_id", client_id),
473-
## ("scope", scopes.into_iter()
474-
## .map(|s| s.as_slice())
475-
## .intersperse(" ")
476-
## .collect::<String>()
477-
## .as_slice())].iter().cloned());
478-
479-
## match self.client.borrow_mut().post(FlowType::Device.as_slice())
480-
## .header(ContentType("application/x-www-form-urlencoded".parse().unwrap()))
481-
## .body(req.as_slice())
482-
## .send() {
483-
## Err(err) => {
484-
## return RequestResult::Error(err);
485-
## }
486-
487465
cmn::Result::Success(response)
488466
}
489467

src/mako/lib/rbuild.mako

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ let rb = hub.${mangle_ident(resource)}();
3939
</%block>
4040
pub struct ${ThisType}
4141
where NC: 'a,
42-
C: 'a,
4342
A: 'a, {
4443
4544
hub: &'a ${hub_type_name}${hub_type_params_s()},

src/mako/lib/util.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
'%': 1,
9999
}
100100

101-
HUB_TYPE_PARAMETERS = ('C', 'NC', 'A')
101+
HUB_TYPE_PARAMETERS = ('NC', 'A')
102102

103103
# ==============================================================================
104104
## @name Filters
@@ -732,7 +732,6 @@ def hub_type_params_s():
732732
# return a list of where statements to server as bounds for the hub.
733733
def hub_type_bounds():
734734
return ['NC: hyper::net::NetworkConnector',
735-
"C: BorrowMut<hyper::Client<NC>> + 'a",
736735
'A: oauth2::GetToken']
737736

738737
# return list of type bounds required by method builder

0 commit comments

Comments
 (0)