file_name
large_stringlengths
4
69
prefix
large_stringlengths
0
26.7k
suffix
large_stringlengths
0
24.8k
middle
large_stringlengths
0
2.12k
fim_type
large_stringclasses
4 values
htmloptionelement.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::CharacterDataBinding::CharacterDataMethods; use dom::bindings::codegen::Bind...
} fn collect_text(node: &JSRef<Node>, value: &mut DOMString) { let elem: JSRef<Element> = ElementCast::to_ref(*node).unwrap(); let svg_script = *elem.namespace() == ns!(SVG) && elem.local_name().as_slice() == "script"; let html_script = node.is_htmlscriptelement(); if svg_script || html_script { ...
{ let element = HTMLOptionElement::new_inherited(localName, prefix, document); Node::reflect_node(box element, document, HTMLOptionElementBinding::Wrap) }
identifier_body
htmloptionelement.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::CharacterDataBinding::CharacterDataMethods; use dom::bindings::codegen::Bind...
<'a>(&'a self) -> Option<&'a VirtualMethods> { let htmlelement: &JSRef<HTMLElement> = HTMLElementCast::from_borrowed_ref(self); Some(htmlelement as &VirtualMethods) } fn after_set_attr(&self, name: &Atom, value: DOMString) { match self.super_type() { Some(ref s) => s.after_s...
super_type
identifier_name
htmloptionelement.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::CharacterDataBinding::CharacterDataMethods; use dom::bindings::codegen::Bind...
let mut content = String::new(); collect_text(&node, &mut content); let v: Vec<&str> = split_html_space_chars(content.as_slice()).collect(); v.connect(" ") } // http://www.whatwg.org/html/#dom-option-text fn SetText(self, value: DOMString) { let node: JSRef<Node> = N...
// http://www.whatwg.org/html/#dom-option-text fn Text(self) -> DOMString { let node: JSRef<Node> = NodeCast::from_ref(self);
random_line_split
htmloptionelement.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::CharacterDataBinding::CharacterDataMethods; use dom::bindings::codegen::Bind...
, _ => () } } fn bind_to_tree(&self, tree_in_doc: bool) { match self.super_type() { Some(ref s) => s.bind_to_tree(tree_in_doc), _ => (), } let node: JSRef<Node> = NodeCast::from_ref(*self); node.check_parent_disabled_state_for_option(...
{ node.set_disabled_state(false); node.set_enabled_state(true); node.check_parent_disabled_state_for_option(); }
conditional_block
cursor.rs
// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use cairo; use gdk_pixbuf; use gdk_sys; use glib::translate::*; use std::fmt; use std::mem; use CursorType; use Display; glib_wrapper! { pub struct Cursor(Object<gdk_sys::GdkCur...
pub fn from_pixbuf(display: &Display, pixbuf: &gdk_pixbuf::Pixbuf, x: i32, y: i32) -> Cursor { skip_assert_initialized!(); unsafe { from_glib_full(gdk_sys::gdk_cursor_new_from_pixbuf( display.to_glib_none().0, pixbuf.to_glib_none().0, x, ...
{ skip_assert_initialized!(); unsafe { from_glib_full(gdk_sys::gdk_cursor_new_from_name( display.to_glib_none().0, name.to_glib_none().0, )) } }
identifier_body
cursor.rs
// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use cairo; use gdk_pixbuf; use gdk_sys; use glib::translate::*; use std::fmt; use std::mem; use CursorType; use Display; glib_wrapper! { pub struct Cursor(Object<gdk_sys::GdkCur...
(display: &Display, surface: &cairo::Surface, x: f64, y: f64) -> Cursor { skip_assert_initialized!(); unsafe { from_glib_full(gdk_sys::gdk_cursor_new_from_surface( display.to_glib_none().0, mut_override(surface.to_glib_none().0), x, ...
from_surface
identifier_name
cursor.rs
// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use cairo; use gdk_pixbuf; use gdk_sys; use glib::translate::*; use std::fmt; use std::mem; use CursorType; use Display; glib_wrapper! { pub struct Cursor(Object<gdk_sys::GdkCur...
let mut x_hot = mem::MaybeUninit::uninit(); let mut y_hot = mem::MaybeUninit::uninit(); let ret = from_glib_full(gdk_sys::gdk_cursor_get_surface( self.to_glib_none().0, x_hot.as_mut_ptr(), y_hot.as_mut_ptr(), )); ...
unsafe { from_glib_full(gdk_sys::gdk_cursor_get_image(self.to_glib_none().0)) } } pub fn get_surface(&self) -> (Option<cairo::Surface>, f64, f64) { unsafe {
random_line_split
sync-rwlock-read-mode-shouldnt-escape.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ let x = ~sync::RWLock::new(); let mut y = None; do x.write_downgrade |write_mode| { y = Some(x.downgrade(write_mode)); } // Adding this line causes a method unification failure instead // do (&option::unwrap(y)).read { } }
identifier_body
sync-rwlock-read-mode-shouldnt-escape.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { let x = ~sync::RWLock::new(); let mut y = None; do x.write_downgrade |write_mode| { y = Some(x.downgrade(write_mode)); } // Adding this line causes a method unification failure instead // do (&option::unwrap(y)).read { } }
main
identifier_name
sync-rwlock-read-mode-shouldnt-escape.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
do x.write_downgrade |write_mode| { y = Some(x.downgrade(write_mode)); } // Adding this line causes a method unification failure instead // do (&option::unwrap(y)).read { } }
use extra::sync; fn main() { let x = ~sync::RWLock::new(); let mut y = None;
random_line_split
span.rs
//! Types representing positions and spans inside source file. use super::Source; use std::rc::Rc; use std::cmp; use std::usize; /// Represent a unique position within all source managed files. #[derive(Clone, Copy, PartialEq, Eq)] pub struct Pos(pub usize); impl Pos { /// Create a span between current position...
(self, other: Span) -> Span { let start = cmp::min(self.start.0, other.start.0); let end = cmp::max(self.end.0, other.end.0); Span::new(Pos(start), Pos(end)) } } /// Represent a position within a single source file. pub struct FatPos { pub source: Rc<Source>, pub pos: usize, } impl...
merge
identifier_name
span.rs
//! Types representing positions and spans inside source file. use super::Source; use std::rc::Rc; use std::cmp; use std::usize; /// Represent a unique position within all source managed files. #[derive(Clone, Copy, PartialEq, Eq)] pub struct Pos(pub usize); impl Pos { /// Create a span between current position...
} } } /// Represent a span within a single source file. pub struct FatSpan { pub source: Rc<Source>, pub start: usize, pub end: usize, } impl FatSpan { pub fn new(src: Rc<Source>, start: usize, end: usize) -> FatSpan { FatSpan { source: src, start: start, ...
FatPos { source: src, pos: pos
random_line_split
rfc2045.rs
//! Module for dealing with RFC2045 style headers. use super::rfc5322::Rfc5322Parser; use std::collections::HashMap; /// Parser over RFC 2045 style headers. /// /// Things of the style `value; param1=foo; param2="bar"` pub struct Rfc2045Parser<'s> { parser: Rfc5322Parser<'s>, } impl<'s> Rfc2045Parser<'s> { /...
/// Consume up to all of the input into the value and a hashmap /// over parameters to values. pub fn consume_all(&mut self) -> (String, HashMap<String, String>) { let value = self.parser.consume_while(|c| c!= ';'); // Find the parameters let mut params = HashMap::new(); w...
{ let token = self.parser.consume_while(|c| { match c { // Not any tspecials '(' | ')' | '<' | '>' | '@' | ',' | ';' | ':' | '\\' | '\"' | '/' | '[' | ']' | '?' | '=' => false, '!'..='~' => true, _ => false, ...
identifier_body
rfc2045.rs
//! Module for dealing with RFC2045 style headers. use super::rfc5322::Rfc5322Parser; use std::collections::HashMap; /// Parser over RFC 2045 style headers. /// /// Things of the style `value; param1=foo; param2="bar"` pub struct Rfc2045Parser<'s> { parser: Rfc5322Parser<'s>, } impl<'s> Rfc2045Parser<'s> { /...
<'s> { input: &'s str, output: (&'s str, Vec<(&'s str, &'s str)>), name: &'s str, } #[test] pub fn test_foo() { let tests = vec![ ParserTestCase { input: "foo/bar", output: ("foo/bar", vec![]), name: "Basic value", ...
ParserTestCase
identifier_name
rfc2045.rs
//! Module for dealing with RFC2045 style headers. use super::rfc5322::Rfc5322Parser; use std::collections::HashMap; /// Parser over RFC 2045 style headers. /// /// Things of the style `value; param1=foo; param2="bar"` pub struct Rfc2045Parser<'s> { parser: Rfc5322Parser<'s>, } impl<'s> Rfc2045Parser<'s> { /...
_ => false, } }); if!token.is_empty() { Some(token) } else { None } } /// Consume up to all of the input into the value and a hashmap /// over parameters to values. pub fn consume_all(&mut self) -> (String, HashMap<Str...
match c { // Not any tspecials '(' | ')' | '<' | '>' | '@' | ',' | ';' | ':' | '\\' | '\"' | '/' | '[' | ']' | '?' | '=' => false, '!'..='~' => true,
random_line_split
user.rs
use std::collections::HashMap; use rustc_serialize::json::Json; use jsonway; use types::WeChatResult; use client::APIClient; use client::response::{User, Followers}; use session::SessionStore; #[derive(Debug, Clone)] pub struct WeChatUser<T: SessionStore> { client: APIClient<T>, } impl<T: SessionStore> WeChatU...
(&self, openid: &str, remark: &str) -> WeChatResult<()> { let data = jsonway::object(|obj| { obj.set("openid", openid.to_owned()); obj.set("remark", remark.to_owned()); }).unwrap(); try!(self.client.post("user/info/updateremark", vec![], &data)); Ok(()) } ...
update_remark
identifier_name
user.rs
use std::collections::HashMap; use rustc_serialize::json::Json; use jsonway; use types::WeChatResult; use client::APIClient; use client::response::{User, Followers}; use session::SessionStore; #[derive(Debug, Clone)] pub struct WeChatUser<T: SessionStore> { client: APIClient<T>, } impl<T: SessionStore> WeChatU...
} } pub fn get(&self, openid: &str) -> WeChatResult<User> { self.get_with_lang(openid, "zh_CN") } pub fn get_with_lang(&self, openid: &str, lang: &str) -> WeChatResult<User> { let res = try!(self.client.get("user/info", vec![("openid", openid), ("lang", lang)])); Ok(sel...
WeChatUser { client: client,
random_line_split
user.rs
use std::collections::HashMap; use rustc_serialize::json::Json; use jsonway; use types::WeChatResult; use client::APIClient; use client::response::{User, Followers}; use session::SessionStore; #[derive(Debug, Clone)] pub struct WeChatUser<T: SessionStore> { client: APIClient<T>, } impl<T: SessionStore> WeChatU...
pub fn get_with_lang(&self, openid: &str, lang: &str) -> WeChatResult<User> { let res = try!(self.client.get("user/info", vec![("openid", openid), ("lang", lang)])); Ok(self.json_to_user(&res)) } pub fn update_remark(&self, openid: &str, remark: &str) -> WeChatResult<()> { let dat...
{ self.get_with_lang(openid, "zh_CN") }
identifier_body
write.rs
use std::time::Instant; use std::io; use std::cell::RefCell; use futures::Future; use tokio_service::Service; use eventstore_tcp::EventStoreClient; use eventstore_tcp::builder::WriteEventsBuilder; use {Config, Command, print_elapsed}; pub struct Write { builder: RefCell<Option<WriteEventsBuilder>>, started: Op...
(&self, config: &Config, client: EventStoreClient) -> Box<dyn Future<Item = (), Error = io::Error>> { use eventstore_tcp::AdaptedMessage; let started = self.started.clone().unwrap(); let package = self.builder.borrow_mut().take().unwrap().build_package(config.credentials.clone(), None); ...
execute
identifier_name
write.rs
use std::time::Instant; use std::io; use std::cell::RefCell; use futures::Future; use tokio_service::Service; use eventstore_tcp::EventStoreClient; use eventstore_tcp::builder::WriteEventsBuilder; use {Config, Command, print_elapsed}; pub struct Write { builder: RefCell<Option<WriteEventsBuilder>>, started: Op...
AdaptedMessage::WriteEventsCompleted(Err(reason)) => { Err(io::Error::new(io::ErrorKind::Other, format!("{}", reason))) }, x => { Err(io::Error::new(io::ErrorKind::Other, format!("Unexpected response: {:?}", x))) } ...
Ok(()) },
random_line_split
write.rs
use std::time::Instant; use std::io; use std::cell::RefCell; use futures::Future; use tokio_service::Service; use eventstore_tcp::EventStoreClient; use eventstore_tcp::builder::WriteEventsBuilder; use {Config, Command, print_elapsed}; pub struct Write { builder: RefCell<Option<WriteEventsBuilder>>, started: Op...
} })) } }
{ Err(io::Error::new(io::ErrorKind::Other, format!("Unexpected response: {:?}", x))) }
conditional_block
cargo_new.rs
pub enum NewProjectKind { Bin, Lib, } impl NewProjectKind { fn is_bin(&self) -> bool { *self == NewProjectKind::Bin } } impl fmt::Display for NewProjectKind { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result
} struct SourceFileInformation { relative_path: String, target_name: String, bin: bool, } struct MkOptions<'a> { version_control: Option<VersionControl>, path: &'a Path, name: &'a str, source_files: Vec<SourceFileInformation>, bin: bool, } impl NewOptions { pub fn new( ve...
{ match *self { NewProjectKind::Bin => "binary (application)", NewProjectKind::Lib => "library", }.fmt(f) }
identifier_body
cargo_new.rs
pub enum NewProjectKind { Bin, Lib, } impl NewProjectKind { fn is_bin(&self) -> bool { *self == NewProjectKind::Bin } } impl fmt::Display for NewProjectKind { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { NewProjectKind::Bin => "binary (applicati...
(bin: bool, project_name: String) -> SourceFileInformation { if bin { SourceFileInformation { relative_path: "src/main.rs".to_string(), target_name: project_name, bin: true, } } else { SourceFileInformation { relative_path: "src/lib.rs".to_...
plan_new_source_file
identifier_name
cargo_new.rs
pub enum NewProjectKind { Bin, Lib, } impl NewProjectKind { fn is_bin(&self) -> bool { *self == NewProjectKind::Bin } } impl fmt::Display for NewProjectKind { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { NewProjectKind::Bin => "binary (applicati...
} // Create Cargo.toml file with necessary [lib] and [[bin]] sections, if needed paths::write( &path.join("Cargo.toml"), format!( r#"[package] name = "{}" version = "0.1.0" authors = [{}] [dependencies] {}"#, name, toml::Value::String(author), ...
{ cargotoml_path_specifier.push_str(&format!( r#" [lib] name = "{}" path = {} "#, i.target_name, toml::Value::String(i.relative_path.clone()) )); }
conditional_block
cargo_new.rs
)] pub enum NewProjectKind { Bin, Lib, } impl NewProjectKind { fn is_bin(&self) -> bool { *self == NewProjectKind::Bin } } impl fmt::Display for NewProjectKind { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { NewProjectKind::Bin => "binary (applica...
paths::write(&path_of_source_file, default_file_content)?; } } if let Err(e) = Workspace::new(&path.join("Cargo.toml"), config) { let msg = format!( "compiling this new crate may not work due to invalid \ workspace configuration\n\n{}", e ...
if !fs::metadata(&path_of_source_file) .map(|x| x.is_file()) .unwrap_or(false) {
random_line_split
test.rs
use generate; use grammar::repr::*; use lr1::core::*; use lr1::interpret::interpret; use lr1::lookahead::Token; use lr1::lookahead::Token::EOF; use lr1::lookahead::TokenSet; use lr1::tls::Lr1Tls; use string_cache::DefaultAtom as Atom; use test_util::{compare, expect_debug, normalized_grammar}; use tls::Tls; use super:...
() { let grammar = normalized_grammar( r#" grammar; extern { enum Tok { "C" =>.., "D" =>.. } } A = B "C"; B: Option<u32> = { "D" => Some(1), () => None }; "#, ); let _lr1_tls = Lr1Tls::install(grammar.terminals.clone()); let items = items(&grammar, "A", 0, EOF); ...
start_state
identifier_name
test.rs
use generate; use grammar::repr::*; use lr1::core::*; use lr1::interpret::interpret; use lr1::lookahead::Token; use lr1::lookahead::Token::EOF; use lr1::lookahead::TokenSet; use lr1::tls::Lr1Tls; use string_cache::DefaultAtom as Atom; use test_util::{compare, expect_debug, normalized_grammar}; use tls::Tls; use super:...
assert!(interpret(&states, tokens!["N", "-"]).is_err()); // unexpected character: assert!(interpret(&states, tokens!["N", "-", ")", "N", "-", "N", "("]).is_err()); // parens first: let tree = interpret(&states, tokens!["(", "N", "-", "N", ")", "-", "N"]).unwrap(); println!("{}", tree); ass...
// incomplete: assert!(interpret(&states, tokens!["N", "-", "(", "N", "-", "N"]).is_err()); // incomplete:
random_line_split
test.rs
use generate; use grammar::repr::*; use lr1::core::*; use lr1::interpret::interpret; use lr1::lookahead::Token; use lr1::lookahead::Token::EOF; use lr1::lookahead::TokenSet; use lr1::tls::Lr1Tls; use string_cache::DefaultAtom as Atom; use test_util::{compare, expect_debug, normalized_grammar}; use tls::Tls; use super:...
let _lr1_tls = Lr1Tls::install(grammar.terminals.clone()); build_lr0_states(&grammar, nt("S")).unwrap_err(); } /// When we moved to storing items as (lr0 -> TokenSet) pairs, a bug /// in the transitive closure routine could cause us to have `(Foo, /// S0)` and `(Foo, S1)` as distinct items instead of `(Foo,...
{ let _tls = Tls::test(); let grammar = normalized_grammar( r#" grammar; S: () = E; E: () = { E "-" T, T, }; T: () = { "N", "(" E ")", }; "#, );
identifier_body
viterbi.rs
use std::f32; use noisy_float::prelude::*; use rayon::prelude::*; type Obs = usize; type State = usize; #[derive(Clone, Copy, Debug)] struct ProbAndPrev { prob: f32, prev: Option<State>, } fn
(obs: &Vec<Obs>, states: &Vec<State>, start_p: &Vec<f32>, trans_p: &Vec<Vec<f32>>, emit_p: &Vec<Vec<f32>>) -> (f32, Vec<State>) { let prevs = { let mut prevs_mut = vec![vec![]; states.len()]; for (prev, currs) in trans_p.iter().enumer...
viterbi_i
identifier_name
viterbi.rs
use std::f32; use noisy_float::prelude::*; use rayon::prelude::*; type Obs = usize; type State = usize; #[derive(Clone, Copy, Debug)] struct ProbAndPrev { prob: f32, prev: Option<State>, } fn viterbi_i(obs: &Vec<Obs>, states: &Vec<State>, start_p: &Vec<f32>, trans_p: &Ve...
emission_p.insert((State::Healthy, Obs::Normal), 0.5); emission_p.insert((State::Healthy, Obs::Cold), 0.4); emission_p.insert((State::Healthy, Obs::Dizzy), 0.1); emission_p.insert((State::Fever, Obs::Normal), 0.1); emission_p.insert((State::Fever, Obs::Cold), 0.3); emission_p.insert((State::Feve...
random_line_split
viterbi.rs
use std::f32; use noisy_float::prelude::*; use rayon::prelude::*; type Obs = usize; type State = usize; #[derive(Clone, Copy, Debug)] struct ProbAndPrev { prob: f32, prev: Option<State>, } fn viterbi_i(obs: &Vec<Obs>, states: &Vec<State>, start_p: &Vec<f32>, trans_p: &Ve...
} } prevs_mut }; let mut v: Vec<Vec<ProbAndPrev>> = vec![vec![ProbAndPrev { prob: f32::NEG_INFINITY, prev: None }; states.len()]; obs.len()]; for st in states.iter() { v[0][*st] = ProbAndPrev { prob: start_p[*st] + emit_p[*st][obs[0]], pr...
{ prevs_mut[curr].push(prev); }
conditional_block
bundle.rs
use derive_collect_docs::CollectDocs; use serde::{Deserialize, Serialize}; use std::{collections::HashMap, path::PathBuf}; pub mod models; pub mod key_map; pub use key_map::{DesktopKeyMap, Error as KeyMapError, MobileKeyMap}; mod modes; pub use modes::{Desktop, Mobile}; mod loading; pub use loading::{Error as LoadEr...
/// Data from `project.yaml` file pub project: models::Project, /// The layouts to be included in this project, read from the `layouts/` /// directory. The layout names are the names of the YAML files without the /// `.yaml` suffix. pub layouts: HashMap<String, models::Layout>, /// Target-spec...
<PathBuf>,
identifier_name
bundle.rs
use derive_collect_docs::CollectDocs; use serde::{Deserialize, Serialize}; use std::{collections::HashMap, path::PathBuf}; pub mod models; pub mod key_map; pub use key_map::{DesktopKeyMap, Error as KeyMapError, MobileKeyMap}; mod modes; pub use modes::{Desktop, Mobile}; mod loading; pub use loading::{Error as LoadEr...
pub x11: Option<models::TargetX11>, pub mim: Option<models::TargetMim>, } /// A `.kbdgen` bundle is a directory with a specific structure. /// /// Please note that the fields listed here are built from the contents of the /// files in the bundle directory. /// ///.Example of the structure of a `.kbdgen` bundle...
pub i_os: Option<models::TargetIOS>, pub mac_os: Option<models::TargetMacOS>, pub windows: Option<models::TargetWindows>, pub chrome: Option<models::TargetChrome>,
random_line_split
pub-struct-field-span-26083.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { }
main
identifier_name
pub-struct-field-span-26083.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
//~^ error: field `bar` is already declared [E0124] bar: u8, pub bar: //~^ error: field `bar` is already declared [E0124] u8, bar: //~^ error: field `bar` is already declared [E0124] u8, } fn main() { }
struct Foo { pub bar: u8, pub
random_line_split
webvr_thread.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use ipc_channel::ipc; use ipc_channel::ipc::{IpcReceiver, IpcSender}; use msg::constellation_msg::PipelineId; use ...
fn handle_reset_pose(&mut self, pipeline: PipelineId, display_id: u32, sender: IpcSender<WebVRResult<VRDisplayData>>) { match self.access_check(pipeline, display_id) { Ok(display) => { display.borrow_mut...
{ match self.access_check(pipeline, display_id) { Ok(display) => { sender.send(Ok(display.borrow().inmediate_frame_data(near, far))).unwrap() }, Err(msg) => sender.send(Err(msg.into())).unwrap() } }
identifier_body
webvr_thread.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use ipc_channel::ipc; use ipc_channel::ipc::{IpcReceiver, IpcSender}; use msg::constellation_msg::PipelineId; use ...
(&self, pipeline: PipelineId, display_id: u32) -> Result<&VRDisplayPtr, &'static str> { if *self.presenting.get(&display_id).unwrap_or(&pipeline)!= pipeline { return Err("No access granted to this Display because it's presenting on other JavaScript Tab"); } self.service.get_display(d...
access_check
identifier_name
webvr_thread.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use ipc_channel::ipc; use ipc_channel::ipc::{IpcReceiver, IpcSender}; use msg::constellation_msg::PipelineId; use ...
webvr_thread_sender: None }); (instance, sender) } } impl webrender_api::VRCompositorHandler for WebVRCompositorHandler { #[allow(unsafe_code)] fn handle(&mut self, cmd: webrender_api::VRCompositorCommand, texture: Option<(u32, DeviceIntSize)>) { match cmd { ...
random_line_split
webvr_thread.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use ipc_channel::ipc; use ipc_channel::ipc::{IpcReceiver, IpcSender}; use msg::constellation_msg::PipelineId; use ...
, WebVRMsg::RequestPresent(pipeline_id, display_id, sender) => { self.handle_request_present(pipeline_id, display_id, sender); }, WebVRMsg::ExitPresent(pipeline_id, display_id, sender) => { self.handle_exit_present(pipeline_id, disp...
{ self.handle_reset_pose(pipeline_id, display_id, sender); }
conditional_block
clients.rs
! version = 2.0 // Learn stuff about our users. + my name is * - <set name=<formal>>Nice to meet you, <get name>. - <set name=<formal>><get name>, nice to meet you. + my name is <bot master> - <set name=<bot master>>That's my master's name too. + my name is <bot name> - <set name=<bot name>>What a coincidence! That...
+ who is my (boyfriend|girlfriend|spouse){weight=10} * <get spouse> == undefined => I don't know. - <get spouse>.
* <get fav<star>> == undefined => I don't know. - Your favorite <star> is <get fav<star>>
random_line_split
functional_test.rs
use std::collections::HashSet; use rand::thread_rng; use schema::*; use Index; use Searcher; use rand::distributions::{IndependentSample, Range}; fn
(searcher: &Searcher, vals: &HashSet<u64>) { assert!(searcher.segment_readers().len() < 20); assert_eq!(searcher.num_docs() as usize, vals.len()); } #[test] #[ignore] fn test_indexing() { let mut schema_builder = SchemaBuilder::default(); let id_field = schema_builder.add_u64_field("id", INT_INDEXED)...
check_index_content
identifier_name
functional_test.rs
use std::collections::HashSet; use rand::thread_rng; use schema::*; use Index; use Searcher; use rand::distributions::{IndependentSample, Range}; fn check_index_content(searcher: &Searcher, vals: &HashSet<u64>) { assert!(searcher.segment_readers().len() < 20); assert_eq!(searcher.num_docs() as usize, vals.len...
} } }
{ uncommitted_docs.insert(random_val); let mut doc = Document::new(); doc.add_u64(id_field, random_val); for i in 1u64..10u64 { doc.add_u64(multiples_field, random_val * i); } index_writer.add_document(do...
conditional_block
functional_test.rs
use std::collections::HashSet; use rand::thread_rng; use schema::*; use Index; use Searcher; use rand::distributions::{IndependentSample, Range}; fn check_index_content(searcher: &Searcher, vals: &HashSet<u64>) { assert!(searcher.segment_readers().len() < 20); assert_eq!(searcher.num_docs() as usize, vals.len...
if random_val == 0 { index_writer.commit().expect("Commit failed"); committed_docs.extend(&uncommitted_docs); uncommitted_docs.clear(); index.load_searchers().unwrap(); let searcher = index.searcher(); // check that everything is correct. ...
{ let mut schema_builder = SchemaBuilder::default(); let id_field = schema_builder.add_u64_field("id", INT_INDEXED); let multiples_field = schema_builder.add_u64_field("multiples", INT_INDEXED); let schema = schema_builder.build(); let index = Index::create_from_tempdir(schema).unwrap(); let...
identifier_body
functional_test.rs
use std::collections::HashSet; use rand::thread_rng; use schema::*; use Index; use Searcher; use rand::distributions::{IndependentSample, Range}; fn check_index_content(searcher: &Searcher, vals: &HashSet<u64>) { assert!(searcher.segment_readers().len() < 20); assert_eq!(searcher.num_docs() as usize, vals.len...
for _ in 0..200 { let random_val = universe.ind_sample(&mut rng); if random_val == 0 { index_writer.commit().expect("Commit failed"); committed_docs.extend(&uncommitted_docs); uncommitted_docs.clear(); index.load_searchers().unwrap(); let s...
let mut committed_docs: HashSet<u64> = HashSet::new(); let mut uncommitted_docs: HashSet<u64> = HashSet::new();
random_line_split
trace.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::js::JS; use dom::bindings::utils::{Reflectable, Reflector}; use js::jsapi::{JSObject, JSTracer...
} impl<S: Encoder<E>, E, T: Encodable<S, E>> Encodable<S, E> for Traceable<RefCell<T>> { fn encode(&self, s: &mut S) -> Result<(), E> { self.borrow().encode(s) } } impl<S: Encoder<E>, E, T: Encodable<S, E>+Copy> Encodable<S, E> for Traceable<Cell<T>> { fn encode(&self, s: &mut S) -> Result<(), E>...
{ &self.inner }
identifier_body
trace.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::js::JS; use dom::bindings::utils::{Reflectable, Reflector}; use js::jsapi::{JSObject, JSTracer...
unsafe { description.to_c_str().with_ref(|name| { (*tracer).debugPrinter = None; (*tracer).debugPrintIndex = -1; (*tracer).debugPrintArg = name as *libc::c_void; debug!("tracing value {:s}", description); JS_CallTracer(tracer, val.to_gcthing(), v...
{ return; }
conditional_block
trace.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::js::JS; use dom::bindings::utils::{Reflectable, Reflector}; use js::jsapi::{JSObject, JSTracer...
fn encode(&self, s: &mut S) -> Result<(), E> { self.deref().get().encode(s) } } impl<S: Encoder<E>, E> Encodable<S, E> for Traceable<*mut JSObject> { fn encode(&self, s: &mut S) -> Result<(), E> { trace_object(get_jstracer(s), "object", **self); Ok(()) } } impl<S: Encoder<E>, E...
} } impl<S: Encoder<E>, E, T: Encodable<S, E>+Copy> Encodable<S, E> for Traceable<Cell<T>> {
random_line_split
trace.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::js::JS; use dom::bindings::utils::{Reflectable, Reflector}; use js::jsapi::{JSObject, JSTracer...
<T> { inner: T } impl<T> Traceable<T> { pub fn new(val: T) -> Traceable<T> { Traceable { inner: val } } } impl<T> Deref<T> for Traceable<T> { fn deref<'a>(&'a self) -> &'a T { &self.inner } } impl<S: Encoder<E>, E, T: Encodable<S, E>> Encodable<S, E> for Tracea...
Traceable
identifier_name
send-resource.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
do task::spawn() { let (pp, cc) = Chan::new(); c.send(cc); let _r = pp.recv(); } p.recv().send(test(42)); }
pub fn main() { let (p, c) = Chan::new();
random_line_split
send-resource.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { let (p, c) = Chan::new(); do task::spawn() { let (pp, cc) = Chan::new(); c.send(cc); let _r = pp.recv(); } p.recv().send(test(42)); }
main
identifier_name
send-resource.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
pub fn main() { let (p, c) = Chan::new(); do task::spawn() { let (pp, cc) = Chan::new(); c.send(cc); let _r = pp.recv(); } p.recv().send(test(42)); }
{ test { f: f } }
identifier_body
mod.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
fn hash(&self, state: &mut S) { (**self).hash(state); } } impl<S: Writer + Hasher, T> Hash<S> for *const T { #[inline] fn hash(&self, state: &mut S) { // NB: raw-pointer Hash does _not_ dereference // to the target; it just gives you the pointer-bytes. (*self as uint).ha...
} } impl<'a, S: Hasher, T: ?Sized + Hash<S>> Hash<S> for &'a mut T { #[inline]
random_line_split
mod.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
} impl<'a, S: Hasher, T:?Sized + Hash<S>> Hash<S> for &'a T { #[inline] fn hash(&self, state: &mut S) { (**self).hash(state); } } impl<'a, S: Hasher, T:?Sized + Hash<S>> Hash<S> for &'a mut T { #[inline] fn hash(&self, state: &mut S) { (**self).hash(state); } } impl<S: Write...
{ self.len().hash(state); for elt in self.iter() { elt.hash(state); } }
identifier_body
mod.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
(&self, state: &mut S) { (**self).hash(state); } } impl<S: Writer + Hasher, T> Hash<S> for *const T { #[inline] fn hash(&self, state: &mut S) { // NB: raw-pointer Hash does _not_ dereference // to the target; it just gives you the pointer-bytes. (*self as uint).hash(state); ...
hash
identifier_name
insert.rs
use super::node::read_unchecked; use super::node::write_node; use super::node::write_targeted; use super::node::NodeWriteGuard; use super::search::mut_search; use super::search::MutSearchResult; use super::*; use std::fmt::Debug; pub struct NodeSplit<KS, PS> where KS: Slice<EntryKey> + Debug +'static, PS: Slic...
} None } pub fn insert_to_tree_node<KS, PS>( tree: &BPlusTree<KS, PS>, node_ref: &NodeCellRef, parent: &NodeCellRef, key: &EntryKey, level: usize, ) -> Option<Option<NodeSplit<KS, PS>>> where KS: Slice<EntryKey> + Debug +'static, PS: Slice<NodeCellRef> +'static, { let search = ...
{ // at this point, root split occurred when waiting for the latch // the new right node should be inserted to any right node of the old root // hopefully that node won't split again let current_root_guard = write_node::<KS, PS>(&current_root); // at this poin...
conditional_block
insert.rs
use super::node::read_unchecked; use super::node::write_node; use super::node::write_targeted; use super::node::NodeWriteGuard; use super::search::mut_search; use super::search::MutSearchResult; use super::*; use std::fmt::Debug; pub struct NodeSplit<KS, PS> where KS: Slice<EntryKey> + Debug +'static, PS: Slic...
tree: &BPlusTree<KS, PS>, node_ref: &NodeCellRef, parent: &NodeCellRef, key: &EntryKey, level: usize, ) -> Option<Option<NodeSplit<KS, PS>>> where KS: Slice<EntryKey> + Debug +'static, PS: Slice<NodeCellRef> +'static, { let search = mut_search::<KS, PS>(node_ref, key); let modificati...
pub fn insert_to_tree_node<KS, PS>(
random_line_split
insert.rs
use super::node::read_unchecked; use super::node::write_node; use super::node::write_targeted; use super::node::NodeWriteGuard; use super::search::mut_search; use super::search::MutSearchResult; use super::*; use std::fmt::Debug; pub struct NodeSplit<KS, PS> where KS: Slice<EntryKey> + Debug +'static, PS: Slic...
<KS, PS>( split_res: Option<NodeSplit<KS, PS>>, parent: &NodeCellRef, ) -> Option<NodeSplit<KS, PS>> where KS: Slice<EntryKey> + Debug +'static, PS: Slice<NodeCellRef> +'static, { match split_res { None => None, Some(split) => { trace!( "Sub level node spl...
insert_internal_tree_node
identifier_name
insert.rs
use super::node::read_unchecked; use super::node::write_node; use super::node::write_targeted; use super::node::NodeWriteGuard; use super::search::mut_search; use super::search::MutSearchResult; use super::*; use std::fmt::Debug; pub struct NodeSplit<KS, PS> where KS: Slice<EntryKey> + Debug +'static, PS: Slic...
} pub fn check_root_modification<KS, PS>( tree: &BPlusTree<KS, PS>, modification: &Option<NodeSplit<KS, PS>>, parent: &NodeCellRef, ) -> Option<NodeSplit<KS, PS>> where KS: Slice<EntryKey> + Debug +'static, PS: Slice<NodeCellRef> +'static, { if let &Some(ref split) = modification { let...
{ // latch nodes from left to right let mut searched_guard = write_targeted(write_node(node_ref), key); let self_ref = searched_guard.node_ref().clone(); debug_assert!( searched_guard.is_ext(), "{:?}", searched_guard.innode().keys ); let mut split_result = searched_guard ...
identifier_body
build.rs
use std::env; use std::fs; use std::path::PathBuf; fn link(name: &str, bundled: bool) { use std::env::var; let target = var("TARGET").unwrap(); let target: Vec<_> = target.split('-').collect(); if target.get(2) == Some(&"windows") { println!("cargo:rustc-link-lib=dylib={}", name); if bu...
fn rocksdb_include_dir() -> String { match env::var("ROCKSDB_INCLUDE_DIR") { Ok(val) => val, Err(_) => "rocksdb/include".to_string(), } } fn bindgen_rocksdb() { let bindings = bindgen::Builder::default() .header(rocksdb_include_dir() + "/rocksdb/c.h") .derive_debug(false) ...
{ if fs::read_dir(name).unwrap().count() == 0 { println!( "The `{}` directory is empty, did you forget to pull the submodules?", name ); println!("Try `git submodule update --init --recursive`"); panic!(); } }
identifier_body
build.rs
use std::env; use std::fs; use std::path::PathBuf; fn link(name: &str, bundled: bool) { use std::env::var; let target = var("TARGET").unwrap(); let target: Vec<_> = target.split('-').collect(); if target.get(2) == Some(&"windows") { println!("cargo:rustc-link-lib=dylib={}", name); if bu...
let target = env::var("TARGET").unwrap(); let endianness = env::var("CARGO_CFG_TARGET_ENDIAN").unwrap(); let mut config = cc::Build::new(); config.include("snappy/"); config.include("."); config.define("NDEBUG", Some("1")); config.extra_warnings(false); if target.contains("msvc") { ...
config.compile("librocksdb.a"); } fn build_snappy() {
random_line_split
build.rs
use std::env; use std::fs; use std::path::PathBuf; fn link(name: &str, bundled: bool) { use std::env::var; let target = var("TARGET").unwrap(); let target: Vec<_> = target.split('-').collect(); if target.get(2) == Some(&"windows") { println!("cargo:rustc-link-lib=dylib={}", name); if bu...
() { bindgen_rocksdb(); if!try_to_find_and_link_lib("ROCKSDB") { println!("cargo:rerun-if-changed=rocksdb/"); fail_on_empty_directory("rocksdb"); build_rocksdb(); } else { let target = env::var("TARGET").unwrap(); // according to https://github.com/alexcrichton/cc-rs...
main
identifier_name
build.rs
use std::env; use std::fs; use std::path::PathBuf; fn link(name: &str, bundled: bool) { use std::env::var; let target = var("TARGET").unwrap(); let target: Vec<_> = target.split('-').collect(); if target.get(2) == Some(&"windows") { println!("cargo:rustc-link-lib=dylib={}", name); if bu...
config.flag_if_supported("-mpclmul"); } } } if target.contains("aarch64") { lib_sources.push("util/crc32c_arm64.cc") } if target.contains("darwin") { config.define("OS_MACOSX", None); config.define("ROCKSDB_PLATFORM_POSIX", None); co...
{ // This is needed to enable hardware CRC32C. Technically, SSE 4.2 is // only available since Intel Nehalem (about 2010) and AMD Bulldozer // (about 2011). let target_feature = env::var("CARGO_CFG_TARGET_FEATURE").unwrap(); let target_features: Vec<_> = target_feature.split(",")...
conditional_block
status_bar.rs
use winapi::shared::minwindef::{WPARAM, LPARAM}; use crate::win32::window_helper as wh; use crate::win32::base_helper::check_hwnd; use crate::{Font, NwgError, RawEventHandler, unbind_raw_event_handler}; use super::{ControlHandle, ControlBase}; use std::cell::RefCell; const NOT_BOUND: &'static str = "StatusBar is not y...
/// Winapi class name used during control creation pub fn class_name(&self) -> &'static str { "msctls_statusbar32" } /// Winapi base flags used during window creation pub fn flags(&self) -> u32 { ::winapi::um::winuser::WS_VISIBLE } /// Winapi flags required by the control...
{ use winapi::um::commctrl::SB_SETTEXTW; use crate::win32::base_helper::to_utf16; let handle = check_hwnd(&self.handle, NOT_BOUND, BAD_HANDLE); let text = to_utf16(text); wh::send_message(handle, SB_SETTEXTW, index as WPARAM, text.as_ptr() as LPARAM); }
identifier_body
status_bar.rs
use winapi::shared::minwindef::{WPARAM, LPARAM}; use crate::win32::window_helper as wh; use crate::win32::base_helper::check_hwnd; use crate::{Font, NwgError, RawEventHandler, unbind_raw_event_handler}; use super::{ControlHandle, ControlBase}; use std::cell::RefCell; const NOT_BOUND: &'static str = "StatusBar is not y...
(self, out: &mut StatusBar) -> Result<(), NwgError> { let parent = match self.parent { Some(p) => Ok(p), None => Err(NwgError::no_parent("StatusBar")) }?; *out = Default::default(); out.handle = ControlBase::build_hwnd() .class_name(out.class_name()) ...
build
identifier_name
status_bar.rs
use winapi::shared::minwindef::{WPARAM, LPARAM}; use crate::win32::window_helper as wh; use crate::win32::base_helper::check_hwnd; use crate::{Font, NwgError, RawEventHandler, unbind_raw_event_handler}; use super::{ControlHandle, ControlBase}; use std::cell::RefCell; const NOT_BOUND: &'static str = "StatusBar is not y...
else { out.set_font(Font::global_default().as_ref()); } out.set_text(0, self.text); out.hook_parent_resize(); Ok(()) } } impl PartialEq for StatusBar { fn eq(&self, other: &Self) -> bool { self.handle == other.handle } }
{ out.set_font(self.font); }
conditional_block
status_bar.rs
use winapi::shared::minwindef::{WPARAM, LPARAM}; use crate::win32::window_helper as wh; use crate::win32::base_helper::check_hwnd; use crate::{Font, NwgError, RawEventHandler, unbind_raw_event_handler}; use super::{ControlHandle, ControlBase}; use std::cell::RefCell; const NOT_BOUND: &'static str = "StatusBar is not y...
} impl Drop for StatusBar { fn drop(&mut self) { let handler = self.handler0.borrow(); if let Some(h) = handler.as_ref() { drop(unbind_raw_event_handler(h)); } self.handle.destroy(); } } pub struct StatusBarBuilder<'a> { text: &'a str, font: Option<&'a Font>...
*self.handler0.borrow_mut() = Some(handler.unwrap()); }
random_line_split
wait.rs
use libc::{pid_t, c_int}; use errno::Errno; use {Error, Result}; mod ffi { use libc::{pid_t, c_int}; extern { pub fn waitpid(pid: pid_t, status: *mut c_int, options: c_int) -> pid_t; } } bitflags!( flags WaitPidFlag: c_int { const WNOHANG = 0x00000001, } ); #[derive(Clone, Copy)]...
(pid: pid_t, options: Option<WaitPidFlag>) -> Result<WaitStatus> { use self::WaitStatus::*; let mut status: i32 = 0; let option_bits = match options { Some(bits) => bits.bits(), None => 0 }; let res = unsafe { ffi::waitpid(pid as pid_t, &mut status as *mut c_int, option_bits) }; ...
waitpid
identifier_name
wait.rs
use libc::{pid_t, c_int}; use errno::Errno; use {Error, Result}; mod ffi { use libc::{pid_t, c_int}; extern { pub fn waitpid(pid: pid_t, status: *mut c_int, options: c_int) -> pid_t; } } bitflags!( flags WaitPidFlag: c_int { const WNOHANG = 0x00000001, } ); #[derive(Clone, Copy)]...
Ok(StillAlive) } else { Ok(Exited(res)) } }
Err(Error::Sys(Errno::last())) } else if res == 0 {
random_line_split
wait.rs
use libc::{pid_t, c_int}; use errno::Errno; use {Error, Result}; mod ffi { use libc::{pid_t, c_int}; extern { pub fn waitpid(pid: pid_t, status: *mut c_int, options: c_int) -> pid_t; } } bitflags!( flags WaitPidFlag: c_int { const WNOHANG = 0x00000001, } ); #[derive(Clone, Copy)]...
{ use self::WaitStatus::*; let mut status: i32 = 0; let option_bits = match options { Some(bits) => bits.bits(), None => 0 }; let res = unsafe { ffi::waitpid(pid as pid_t, &mut status as *mut c_int, option_bits) }; if res < 0 { Err(Error::Sys(Errno::last())) } els...
identifier_body
glue.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #![allow(unsafe_code)] use app_units::Au; use data::PerDocumentStyleData; use env_logger; use euclid::Size2D; use...
#[no_mangle] pub extern "C" fn Servo_AddRefStyleSheet(sheet: *mut RawServoStyleSheet) -> () { type Helpers = ArcHelpers<RawServoStyleSheet, Stylesheet>; unsafe { Helpers::addref(sheet) }; } #[no_mangle] pub extern "C" fn Servo_ReleaseStyleSheet(sheet: *mut RawServoStyleSheet) -> () { type Helpers = ArcHelp...
pub extern "C" fn Servo_StyleSheetHasRules(raw_sheet: *mut RawServoStyleSheet) -> bool { type Helpers = ArcHelpers<RawServoStyleSheet, Stylesheet>; Helpers::with(raw_sheet, |sheet| !sheet.rules.is_empty()) }
random_line_split
glue.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #![allow(unsafe_code)] use app_units::Au; use data::PerDocumentStyleData; use env_logger; use euclid::Size2D; use...
#[no_mangle] pub extern "C" fn Servo_ReleaseStyleSheet(sheet: *mut RawServoStyleSheet) -> () { type Helpers = ArcHelpers<RawServoStyleSheet, Stylesheet>; unsafe { Helpers::release(sheet) }; } #[no_mangle] pub extern "C" fn Servo_GetComputedValues(node: *mut RawGeckoNode) -> *mut ServoComputedValues { ...
{ type Helpers = ArcHelpers<RawServoStyleSheet, Stylesheet>; unsafe { Helpers::addref(sheet) }; }
identifier_body
glue.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #![allow(unsafe_code)] use app_units::Au; use data::PerDocumentStyleData; use env_logger; use euclid::Size2D; use...
(ptr: *mut GeckoType) { let _ = Self::into(ptr); } } #[no_mangle] pub extern "C" fn Servo_AppendStyleSheet(raw_sheet: *mut RawServoStyleSheet, raw_data: *mut RawServoStyleSet) { type Helpers = ArcHelpers<RawServoStyleSheet, Stylesheet>; let data = PerDocumen...
release
identifier_name
generate.rs
// Copyright (c) 2016 Chef Software Inc. and/or applicable contributors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless r...
(ui: &mut UI, origin: &str, cache: &Path) -> Result<()> { match ident::is_valid_origin_name(origin) { false => Err(Error::from(InvalidOrigin(origin.to_string()))), true => { ui.begin(format!("Generating origin key for {}", &origin))?; let pair = SigKeyPair::generate_pair_for_...
start
identifier_name
generate.rs
// Copyright (c) 2016 Chef Software Inc. and/or applicable contributors
// // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language gov...
// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at
random_line_split
generate.rs
// Copyright (c) 2016 Chef Software Inc. and/or applicable contributors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless r...
{ match ident::is_valid_origin_name(origin) { false => Err(Error::from(InvalidOrigin(origin.to_string()))), true => { ui.begin(format!("Generating origin key for {}", &origin))?; let pair = SigKeyPair::generate_pair_for_origin(origin)?; pair.to_pair_files(cache)?;...
identifier_body
parser.rs
use super::*; use common::{BfResult, Error}; /// Parses Brainfuck concrete syntax into an abstract syntax tree. /// /// # Errors /// /// Unmatched square brackets will result in an `Err` return. See /// [`common::Error`](../common/enum.Error.html). pub fn parse_program(input: &[u8]) -> BfResult<Box<Program>> { let...
let mut instructions = Vec::new(); loop { match parse_instruction(input) { Ok((Some(instruction), next_input)) => { instructions.push(instruction); input = next_input; } Ok((None, next_input)) => { input = next_input; ...
} } fn parse_instructions(mut input: &[u8]) -> Parser<Box<Program>> {
random_line_split
parser.rs
use super::*; use common::{BfResult, Error}; /// Parses Brainfuck concrete syntax into an abstract syntax tree. /// /// # Errors /// /// Unmatched square brackets will result in an `Err` return. See /// [`common::Error`](../common/enum.Error.html). pub fn parse_program(input: &[u8]) -> BfResult<Box<Program>> { let...
() { assert_parse("[]", &[mk_loop(vec![])]); } #[test] fn non_empty_loop_parses() { assert_parse("[<]", &[mk_loop(vec![Cmd(Left)])]); assert_parse("[<.>]", &[mk_loop(vec![Cmd(Left), Cmd(Out), Cmd(Right)])]); } #[test] fn nested_loops_parse() { assert_parse("[<[]...
empty_loop_parses
identifier_name
parser.rs
use super::*; use common::{BfResult, Error}; /// Parses Brainfuck concrete syntax into an abstract syntax tree. /// /// # Errors /// /// Unmatched square brackets will result in an `Err` return. See /// [`common::Error`](../common/enum.Error.html). pub fn parse_program(input: &[u8]) -> BfResult<Box<Program>> { let...
fn assert_parse_error(input: &str, message: Error) { assert_eq!(parse_program(input.as_bytes()), Err(message)); } fn mk_loop(instructions: Vec<Statement>) -> Statement { Statement::Loop(instructions.into_boxed_slice()) } }
{ assert_eq!(parse_program(input.as_bytes()), Ok(program.to_vec().into_boxed_slice())); }
identifier_body
mod.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} // Again, unsafe because this has incredibly dubious ownership violations. // It is assumed that this buffer is immediately dropped. unsafe fn resize(&self, b: isize, t: isize, delta: isize) -> Buffer<T> { // NB: not entirely obvious, but thanks to 2's complement, // casting delta to ...
random_line_split
mod.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(&self) -> Option<T> { unsafe { self.deque.pop() } } /// Gets access to the buffer pool that this worker is attached to. This can /// be used to create more deques which share the same buffer pool as this /// deque. pub fn pool<'a>(&'a self) -> &'a BufferPool<T> { &self.deque.pool ...
pop
identifier_name
mod.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
self.pool.free(transmute(old)); return newbuf; } } #[unsafe_destructor] impl<T: Send +'static> Drop for Deque<T> { fn drop(&mut self) { let t = self.top.load(SeqCst); let b = self.bottom.load(SeqCst); let a = self.array.load(SeqCst); // Free whatever is leftove...
{ self.bottom.store(b, SeqCst); }
conditional_block
print_diff.rs
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ use colored::Colorize; use diff::Result::*; /// Prints a diff between the expected and actual strings to stdout. pub(crate) fn pri...
} }
random_line_split
print_diff.rs
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ use colored::Colorize; use diff::Result::*; /// Prints a diff between the expected and actual strings to stdout. pub(crate) fn pri...
{ match result { Left(_) | Right(_) => true, _ => false, } }
identifier_body
print_diff.rs
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ use colored::Colorize; use diff::Result::*; /// Prints a diff between the expected and actual strings to stdout. pub(crate) fn pri...
<T>(result: &diff::Result<T>) -> bool { match result { Left(_) | Right(_) => true, _ => false, } }
is_change
identifier_name
app_data.rs
use std::path::PathBuf; use gdk_pixbuf::*; use core_compat::entity::resource_file::ResourceFile; pub struct AppData { pub current_path: PathBuf, pub current_file: PathBuf, pub resource_file: Option<ResourceFile>, pub resource_idx: isize, pub resource_total: usize, pub height: usize, pub w...
let img_vec = { let resource = &resource_file.resources[idx]; self.width = resource.width as usize; self.height = resource.height as usize; self.offset_x = resource.offset_x as usize; self.offset_y = resource.offset_y as usize;...
{ return; }
conditional_block
app_data.rs
use std::path::PathBuf; use gdk_pixbuf::*; use core_compat::entity::resource_file::ResourceFile; pub struct AppData { pub current_path: PathBuf, pub current_file: PathBuf, pub resource_file: Option<ResourceFile>, pub resource_idx: isize, pub resource_total: usize, pub height: usize, pub w...
pub fn load_rle_at_idx(&mut self, idx: usize) { if self.resource_file.is_some() { let resource_file = self.resource_file.as_ref().unwrap(); if idx > resource_file.resources.len() { return; } let img_vec = { let resource = &reso...
pixbuf: None, } }
random_line_split
app_data.rs
use std::path::PathBuf; use gdk_pixbuf::*; use core_compat::entity::resource_file::ResourceFile; pub struct AppData { pub current_path: PathBuf, pub current_file: PathBuf, pub resource_file: Option<ResourceFile>, pub resource_idx: isize, pub resource_total: usize, pub height: usize, pub w...
(&mut self, idx: usize) { if self.resource_file.is_some() { let resource_file = self.resource_file.as_ref().unwrap(); if idx > resource_file.resources.len() { return; } let img_vec = { let resource = &resource_file.resources[idx]; ...
load_rle_at_idx
identifier_name
item.rs
use std::any::Any; use std::any::TypeId; use std::fmt; use std::str::from_utf8; use super::cell::{OptCell, PtrMapCell}; use header::{Header, MultilineFormatter, Raw}; #[derive(Clone)] pub struct Item { raw: OptCell<Raw>, typed: PtrMapCell<Header + Send + Sync> } impl Item { #[inline] pub fn new_raw(...
}.map(|typed| unsafe { typed.downcast_ref_unchecked() }) } pub fn typed_mut<H: Header>(&mut self) -> Option<&mut H> { let tid = TypeId::of::<H>(); if self.typed.get_mut(tid).is_none() { match parse::<H>(self.raw.as_ref().expect("item.raw must exist")) { Ok(t...
{ match parse::<H>(self.raw.as_ref().expect("item.raw must exist")) { Ok(typed) => { unsafe { self.typed.insert(tid, typed); } self.typed.get(tid) }, Err(_) => None } }
conditional_block
item.rs
use std::any::Any; use std::any::TypeId; use std::fmt; use std::str::from_utf8; use super::cell::{OptCell, PtrMapCell}; use header::{Header, MultilineFormatter, Raw}; #[derive(Clone)] pub struct Item { raw: OptCell<Raw>, typed: PtrMapCell<Header + Send + Sync> } impl Item { #[inline] pub fn new_raw(...
None => parse::<H>(self.raw.as_ref().expect("item.raw must exist")).ok() }.map(|typed| unsafe { typed.downcast_unchecked() }) } pub fn write_h1(&self, f: &mut MultilineFormatter) -> fmt::Result { match *self.raw { Some(ref raw) => { for part in raw.iter()...
random_line_split
item.rs
use std::any::Any; use std::any::TypeId; use std::fmt; use std::str::from_utf8; use super::cell::{OptCell, PtrMapCell}; use header::{Header, MultilineFormatter, Raw}; #[derive(Clone)] pub struct Item { raw: OptCell<Raw>, typed: PtrMapCell<Header + Send + Sync> } impl Item { #[inline] pub fn new_raw(...
} } } #[inline] fn parse<H: Header>(raw: &Raw) -> ::Result<Box<Header + Send + Sync>> { H::parse_header(raw).map(|h| { let h: Box<Header + Send + Sync> = Box::new(h); h }) }
{ match *self.raw { Some(ref raw) => { for part in raw.iter() { match from_utf8(&part[..]) { Ok(s) => { try!(f.fmt_line(&s)); }, Err(_) => { ...
identifier_body
item.rs
use std::any::Any; use std::any::TypeId; use std::fmt; use std::str::from_utf8; use super::cell::{OptCell, PtrMapCell}; use header::{Header, MultilineFormatter, Raw}; #[derive(Clone)] pub struct Item { raw: OptCell<Raw>, typed: PtrMapCell<Header + Send + Sync> } impl Item { #[inline] pub fn new_raw(...
(&mut self) -> &mut Raw { self.raw(); self.typed = PtrMapCell::new(); unsafe { self.raw.get_mut() } } pub fn raw(&self) -> &Raw { if let Some(ref raw) = *self.raw { return raw; } let raw = unsafe { self.typed.one() }.to_string().i...
raw_mut
identifier_name
source_printer.rs
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ use colored::*; use common::Span; use std::fmt::Write; #[derive(Default)] pub struct
; const PRINT_WHITESPACE: bool = false; impl SourcePrinter { pub fn write_span<W: Write>( &self, writer: &mut W, span: &Span, source: &str, ) -> std::fmt::Result { let start_char_index = span.start as usize; let end_char_index = span.end as usize; let s...
SourcePrinter
identifier_name
source_printer.rs
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ use colored::*; use common::Span; use std::fmt::Write; #[derive(Default)] pub struct SourcePrinter; const PRINT_WHITESPACE: bool ...
for (byte_index, chr) in source.char_indices() { if chr == '\n' { line_end_byte_indices.push(byte_index + 1) } } if source.ends_with('\n') { line_end_byte_indices.pop(); } let byte_index_to_line_index = |byte_index: usize| -> u...
{ let start_char_index = span.start as usize; let end_char_index = span.end as usize; let start_byte_index = if let Some((byte_index, _)) = source.char_indices().nth(start_char_index) { byte_index } else { return write!( ...
identifier_body
source_printer.rs
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ use colored::*; use common::Span; use std::fmt::Write; #[derive(Default)] pub struct SourcePrinter; const PRINT_WHITESPACE: bool ...
// TODO should push 2 spaces for emojis, unicode-width crate might help marker.push(' '); } } } writeln!(writer)?; if something_highlighted_on_line { writeln!(writer, " \u{2502} {...
currently_hightlighted = false; } } else { write!(writer, "{}", chr).unwrap(); if !something_highlighted_on_line {
random_line_split
mips_unknown_linux_uclibc.rs
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
features: "+mips32r2,+soft-float".to_string(), max_atomic_width: Some(32), ..super::linux_base::opts() }, }) }
linker_flavor: LinkerFlavor::Gcc, options: TargetOptions { cpu: "mips32r2".to_string(),
random_line_split
mips_unknown_linux_uclibc.rs
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() -> TargetResult { Ok(Target { llvm_target: "mips-unknown-linux-uclibc".to_string(), target_endian: "big".to_string(), target_pointer_width: "32".to_string(), target_c_int_width: "32".to_string(), data_layout: "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".to_string(), ...
target
identifier_name
mips_unknown_linux_uclibc.rs
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
}
{ Ok(Target { llvm_target: "mips-unknown-linux-uclibc".to_string(), target_endian: "big".to_string(), target_pointer_width: "32".to_string(), target_c_int_width: "32".to_string(), data_layout: "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".to_string(), arch: "mips"....
identifier_body
traveling_salesman_problem.rs
use graph::Graph; use adjacency_matrix::AdjacencyMatrix; pub fn traveling_salesman_problem(g: &Graph) -> Vec<usize> { if g.vertex_count == 0
let m = AdjacencyMatrix::from_graph(&g); optimize_tour(&construct_tour(&m), &m) } // construct_tour incrementally inserts the furthest vertex to create a tour. fn construct_tour(m: &AdjacencyMatrix) -> Vec<usize> { let mut tour = vec![0]; while tour.len() < m.size() { let (x, index) = furthest...
{ return vec![]; }
conditional_block
traveling_salesman_problem.rs
use graph::Graph; use adjacency_matrix::AdjacencyMatrix; pub fn traveling_salesman_problem(g: &Graph) -> Vec<usize> { if g.vertex_count == 0 { return vec![]; } let m = AdjacencyMatrix::from_graph(&g); optimize_tour(&construct_tour(&m), &m) } // construct_tour incrementally inserts the furthest...
(tour: &Vec<usize>, m: &AdjacencyMatrix) -> Vec<usize> { let mut optimized_tour = tour.to_vec(); while let Some(swapped_tour) = find_optimized_tour(&optimized_tour, m) { optimized_tour = swapped_tour } optimized_tour } // find_optimized_tour tries to return a new tour obtained by swapping two v...
optimize_tour
identifier_name
traveling_salesman_problem.rs
use graph::Graph; use adjacency_matrix::AdjacencyMatrix; pub fn traveling_salesman_problem(g: &Graph) -> Vec<usize> { if g.vertex_count == 0 { return vec![]; } let m = AdjacencyMatrix::from_graph(&g); optimize_tour(&construct_tour(&m), &m) } // construct_tour incrementally inserts the furthest...
let (x, (index, _)) = (0..m.size()) .filter(|x|!tour.contains(x)) .map(|x| (x, smallest_insertion(x, tour, m))) .max_by_key(|&(_, (_, distance))| distance) .unwrap(); (x, index) } // smallest_insertion finds where x should be inserted in tour to add the smallest amount of // distan...
random_line_split