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 |
|---|---|---|---|---|
statusbar.rs | // This file is part of rgtk.
//
// rgtk is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// rgtk is distributed in the hop... | -> Option<StatusBar> {
let tmp_pointer = unsafe { ffi::gtk_statusbar_new() };
check_pointer!(tmp_pointer, StatusBar)
}
pub fn push(&mut self, context_id: u32, text: &str) -> u32 {
unsafe {
text.with_c_str(|c_str| {
ffi::gtk_statusbar_push(GTK_STATUSBAR(self.... | w() | identifier_name |
statusbar.rs | // This file is part of rgtk.
//
// rgtk is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// rgtk is distributed in the hop... | pub fn remove(&mut self, context_id: u32, message_id: u32) {
unsafe {
ffi::gtk_statusbar_remove(GTK_STATUSBAR(self.pointer), context_id, message_id)
}
}
pub fn remove_all(&mut self, context_id: u32) {
unsafe {
ffi::gtk_statusbar_remove_all(GTK_STATUSBAR(self.... | unsafe {
ffi::gtk_statusbar_pop(GTK_STATUSBAR(self.pointer), context_id)
}
}
| identifier_body |
statusbar.rs | // This file is part of rgtk.
//
// rgtk is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// rgtk is distributed in the hop... | use gtk::{mod, ffi};
/// GtkViewport — An adapter which makes widgets scrollable
struct_Widget!(StatusBar)
impl StatusBar {
pub fn new() -> Option<StatusBar> {
let tmp_pointer = unsafe { ffi::gtk_statusbar_new() };
check_pointer!(tmp_pointer, StatusBar)
}
pub fn push(&mut self, context_id... | // along with rgtk. If not, see <http://www.gnu.org/licenses/>.
//! An adapter which makes widgets scrollable
use gtk::cast::GTK_STATUSBAR; | random_line_split |
build.rs | //#![feature(plugin)]
//#![plugin(bindgen_plugin)]
//#[allow(dead_code, uppercase_variables, non_camel_case_types)]
//#[plugin(bindgen_plugin)]
//mod mysql_bindings {
// bindgen!("/usr/include/mysql/mysql.h", match="mysql.h", link="mysql");
//}
//use std::env;
//use std::fs;
//use std::path::Path;
//use std:... |
println!("cargo:rustc-flags=-l dylib=crypto");
println!("cargo:rustc-flags=-l dylib=ssl");
println!("cargo:rustc-flags=-l dylib=stdc++");
println!("cargo:rustc-flags=-l dylib=uv");
println!("cargo:rustc-link-search={}", "/usr/lib/x86_64-linux-gnu");
println!("cargo:rustc-link-search={}", "/usr/... | {
for p in datastax_dir.split(";") {
println!("cargo:rustc-link-search={}", p);
}
} | conditional_block |
build.rs | //#![feature(plugin)]
//#![plugin(bindgen_plugin)]
//#[allow(dead_code, uppercase_variables, non_camel_case_types)]
//#[plugin(bindgen_plugin)]
//mod mysql_bindings {
// bindgen!("/usr/include/mysql/mysql.h", match="mysql.h", link="mysql");
//}
//use std::env;
//use std::fs;
//use std::path::Path;
//use std:... | println!("cargo:rustc-link-search={}", "/usr/local/lib");
println!("cargo:rustc-link-search={}", "/usr/lib64/");
println!("cargo:rustc-link-search={}", "/usr/lib/");
println!("cargo:rustc-link-lib=static=cassandra_static");
}
| {
let _ = libbindgen::builder()
.header("cassandra.h")
.use_core()
.generate().unwrap()
.write_to_file(Path::new("./src/").join("cassandra.rs"));
if let Some(datastax_dir) = option_env!("CASSANDRA_SYS_LIB_PATH") {
for p in datastax_dir.split(";") {
println!("cargo:rustc-link-... | identifier_body |
build.rs | //#![feature(plugin)]
//#![plugin(bindgen_plugin)]
//#[allow(dead_code, uppercase_variables, non_camel_case_types)]
//#[plugin(bindgen_plugin)]
//mod mysql_bindings {
// bindgen!("/usr/include/mysql/mysql.h", match="mysql.h", link="mysql");
//}
//use std::env;
//use std::fs;
//use std::path::Path;
//use std:... | println!("cargo:rustc-link-search={}", "/usr/local/lib");
println!("cargo:rustc-link-search={}", "/usr/lib64/");
println!("cargo:rustc-link-search={}", "/usr/lib/");
println!("cargo:rustc-link-lib=static=cassandra_static");
} | random_line_split | |
build.rs | //#![feature(plugin)]
//#![plugin(bindgen_plugin)]
//#[allow(dead_code, uppercase_variables, non_camel_case_types)]
//#[plugin(bindgen_plugin)]
//mod mysql_bindings {
// bindgen!("/usr/include/mysql/mysql.h", match="mysql.h", link="mysql");
//}
//use std::env;
//use std::fs;
//use std::path::Path;
//use std:... | () {
let _ = libbindgen::builder()
.header("cassandra.h")
.use_core()
.generate().unwrap()
.write_to_file(Path::new("./src/").join("cassandra.rs"));
if let Some(datastax_dir) = option_env!("CASSANDRA_SYS_LIB_PATH") {
for p in datastax_dir.split(";") {
println!("cargo:rustc-link-s... | main | identifier_name |
pending.rs | use core::marker;
use core::pin::Pin;
use futures_core::future::{FusedFuture, Future};
use futures_core::task::{Context, Poll};
/// Future for the [`pending()`] function.
#[derive(Debug)]
#[must_use = "futures do nothing unless you `.await` or poll them"]
pub struct Pending<T> {
_data: marker::PhantomData<T>,
}
i... | (&self) -> Self {
pending()
}
}
| clone | identifier_name |
pending.rs | use core::marker;
use core::pin::Pin;
use futures_core::future::{FusedFuture, Future};
use futures_core::task::{Context, Poll};
/// Future for the [`pending()`] function. | pub struct Pending<T> {
_data: marker::PhantomData<T>,
}
impl<T> FusedFuture for Pending<T> {
fn is_terminated(&self) -> bool {
true
}
}
/// Creates a future which never resolves, representing a computation that never
/// finishes.
///
/// The returned future will forever return [`Poll::Pending`].... | #[derive(Debug)]
#[must_use = "futures do nothing unless you `.await` or poll them"] | random_line_split |
conversions.rs | use std::str::FromStr;
use super::errors::TcpTransportError;
use super::typedefs::TcpTransportResult;
pub fn as_string(bytes: Vec<u8>) -> TcpTransportResult<String> {
match String::from_utf8(bytes) {
Ok(st) => Ok(st),
Err(_) => Err(TcpTransportError::Utf8Error),
}
}
pub fn as_number<N: FromS... |
// bytestring is not utf8
let err = as_string(vec![b'a', 254, b'b']).unwrap_err();
assert_eq!(err, TcpTransportError::Utf8Error);
}
#[test]
fn test_as_number() {
// bytestring is a number
let num = as_number::<u64>(vec![b'1', b'2']).unwrap();
assert_eq!(num,... | fn test_as_string() {
// bytestring is utf8
let st = as_string(vec![b'a', b'b']).unwrap();
assert_eq!(st, "ab".to_string()); | random_line_split |
conversions.rs | use std::str::FromStr;
use super::errors::TcpTransportError;
use super::typedefs::TcpTransportResult;
pub fn | (bytes: Vec<u8>) -> TcpTransportResult<String> {
match String::from_utf8(bytes) {
Ok(st) => Ok(st),
Err(_) => Err(TcpTransportError::Utf8Error),
}
}
pub fn as_number<N: FromStr>(bytes: Vec<u8>) -> TcpTransportResult<N> {
let string = try!(as_string(bytes));
match string.parse::<N>() {
... | as_string | identifier_name |
conversions.rs | use std::str::FromStr;
use super::errors::TcpTransportError;
use super::typedefs::TcpTransportResult;
pub fn as_string(bytes: Vec<u8>) -> TcpTransportResult<String> {
match String::from_utf8(bytes) {
Ok(st) => Ok(st),
Err(_) => Err(TcpTransportError::Utf8Error),
}
}
pub fn as_number<N: FromS... |
#[cfg(test)]
mod tests {
use tcp_transport::TcpTransportError;
use super::as_number;
use super::as_string;
#[test]
fn test_as_string() {
// bytestring is utf8
let st = as_string(vec![b'a', b'b']).unwrap();
assert_eq!(st, "ab".to_string());
// bytestring is not... | {
let string = try!(as_string(bytes));
match string.parse::<N>() {
Ok(num) => Ok(num),
Err(_) => Err(TcpTransportError::NumberParseError),
}
} | identifier_body |
os.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 ... |
}
}
pub fn unsetenv(n: &OsStr) {
unsafe {
let nbuf = n.to_cstring().unwrap();
if libc::funcs::posix01::unistd::unsetenv(nbuf.as_ptr())!= 0 {
panic!("failed unsetenv: {}", io::Error::last_os_error());
}
}
}
pub fn page_size() -> usize {
unsafe {
libc::syscon... | {
panic!("failed setenv: {}", io::Error::last_os_error());
} | conditional_block |
os.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 ... | if sz == 0 { return Err(io::Error::last_os_error()); }
v.set_len(sz as usize - 1); // chop off trailing NUL
Ok(PathBuf::from(OsString::from_vec(v)))
}
}
#[cfg(target_os = "dragonfly")]
pub fn current_exe() -> io::Result<PathBuf> {
::fs::read_link("/proc/curproc/file")
}
#[cfg(any(targe... | ptr::null_mut(), 0 as libc::size_t);
if err != 0 { return Err(io::Error::last_os_error()); } | random_line_split |
os.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 ... | () -> usize {
unsafe {
libc::sysconf(libc::_SC_PAGESIZE) as usize
}
}
pub fn temp_dir() -> PathBuf {
getenv("TMPDIR".as_ref()).map(os2path).unwrap_or_else(|| {
if cfg!(target_os = "android") {
PathBuf::from("/data/local/tmp")
} else {
PathBuf::from("/tmp")
... | page_size | identifier_name |
os.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 ... |
fn size_hint(&self) -> (usize, Option<usize>) { self.iter.size_hint() }
}
#[derive(Debug)]
pub struct JoinPathsError;
pub fn join_paths<I, T>(paths: I) -> Result<OsString, JoinPathsError>
where I: Iterator<Item=T>, T: AsRef<OsStr>
{
let mut joined = Vec::new();
let sep = b':';
for (i, path) in p... | { self.iter.next() } | identifier_body |
dst-dtor-2.rs | // Copyright 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-MIT or ... | (&mut self) {
unsafe { DROP_RAN += 1; }
}
}
struct Fat<T:?Sized> {
f: T
}
pub fn main() {
{
let _x: Box<Fat<[Foo]>> = box Fat { f: [Foo, Foo, Foo] };
}
unsafe {
assert!(DROP_RAN == 3);
}
}
| drop | identifier_name |
dst-dtor-2.rs | // Copyright 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-MIT or ... | let _x: Box<Fat<[Foo]>> = box Fat { f: [Foo, Foo, Foo] };
}
unsafe {
assert!(DROP_RAN == 3);
}
} | { | random_line_split |
dst-dtor-2.rs | // Copyright 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-MIT or ... | {
{
let _x: Box<Fat<[Foo]>> = box Fat { f: [Foo, Foo, Foo] };
}
unsafe {
assert!(DROP_RAN == 3);
}
} | identifier_body | |
issue-410.rs | #![allow(
dead_code,
non_snake_case,
non_camel_case_types,
non_upper_case_globals
)]
#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)]
pub mod root {
#[allow(unused_imports)]
use self::super::root;
pub mod JS {
#[allow(unused_imports)]
use self::super::s... | {
pub _address: u8,
}
#[test]
fn bindgen_test_layout_Value() {
assert_eq!(
::std::mem::size_of::<Value>(),
1usize,
concat!("Size of: ", stringify!(Value))
);
assert_eq!(
::std::mem::a... | Value | identifier_name |
issue-410.rs | #![allow(
dead_code,
non_snake_case,
non_camel_case_types,
non_upper_case_globals
)]
#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)]
pub mod root {
#[allow(unused_imports)]
use self::super::root;
pub mod JS {
#[allow(unused_imports)]
use self::super::s... | 1usize,
concat!("Alignment of ", stringify!(Value))
);
}
extern "C" {
#[link_name = "\u{1}_ZN2JS5Value1aE10JSWhyMagic"]
pub fn Value_a(this: *mut root::JS::Value, arg1: root::JSWhyMagic);
}
impl Value {
#[inl... | assert_eq!(
::std::mem::align_of::<Value>(), | random_line_split |
handshake.rs | // Copyright 2016 The Grin Developers
//
// 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 required by applicable law or agree... | // all good, keep peer info
let peer_info = PeerInfo {
capabilities: hand.capabilities,
user_agent: hand.user_agent,
addr: hand.sender_addr.0,
version: hand.version,
total_difficulty: hand.total_difficulty,
};
// send our reply with our info
let shake = Shake {
version:... | {
let nonces = self.nonces.clone();
Box::new(read_msg::<Hand>(conn)
.and_then(move |(conn, hand)| {
if hand.version != 1 {
return Err(Error::Serialization(ser::Error::UnexpectedData {
expected: vec![PROTOCOL_VERSION as u8],
received: vec![hand.version as u8],
}));
}
{
// ch... | identifier_body |
handshake.rs | // You may obtain a copy of the License at
//
// 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.
// Se... | // Copyright 2016 The Grin Developers
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. | random_line_split | |
handshake.rs | // Copyright 2016 The Grin Developers
//
// 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 required by applicable law or agree... | (&self,
capab: Capabilities,
total_difficulty: Difficulty,
conn: TcpStream)
-> Box<Future<Item = (TcpStream, ProtocolV1, PeerInfo), Error = Error>> {
let nonces = self.nonces.clone();
Box::new(read_msg::<Hand>(conn)
.and_then(move |(conn, ha... | handshake | identifier_name |
handshake.rs | // Copyright 2016 The Grin Developers
//
// 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 required by applicable law or agree... |
nonce
}
}
| {
nonces.pop_front();
} | conditional_block |
destructured-fn-argument.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 ... | (rr: int, (ss, tt): (int, int)) {
zzz();
}
nested_function(60, (61, 62));
}
fn zzz() {()}
| nested_function | identifier_name |
destructured-fn-argument.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 ... |
fn different_order_of_struct_fields(Struct { b: s, a: t }: Struct ) {
zzz();
}
fn complex_nesting(((u, v ), ((w, (x, Struct { a: y, b: z})), Struct { a: ae, b: oe }), ue ):
((i16, i32), ((i64, (i32, Struct, )), Struct ), u16)) {
zzz();
}
fn managed_box(@... | {
zzz();
} | identifier_body |
destructured-fn-argument.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 ... |
// debugger:finish
// debugger:print kk
// check:$40 = 53
// debugger:print ll
// check:$41 = 54
// debugger:continue
// debugger:finish
// debugger:print mm
// check:$42 = 55
// debugger:print *nn
// check:$43 = 56
// debugger:continue
// debugger:finish
// debugger:print oo
// check:$44 = 57
// debugger:print pp
/... | // debugger:print *jj
// check:$39 = 52
// debugger:continue | random_line_split |
titles.rs | #![crate_name = "foo"]
// @matches 'foo/index.html' '//h1' 'Crate foo'
// @matches 'foo/foo_mod/index.html' '//h1' 'Module foo::foo_mod'
pub mod foo_mod {
pub struct __Thing {}
}
extern "C" {
// @matches 'foo/fn.foo_ffn.html' '//h1' 'Function foo::foo_ffn'
pub fn foo_ffn();
}
// @matches 'foo/fn.foo_fn.... | // @matches 'foo/primitive.bool.html' '//h1' 'Primitive Type bool'
#[doc(primitive = "bool")]
mod bool {}
// @matches 'foo/static.FOO_STATIC.html' '//h1' 'Static foo::FOO_STATIC'
pub static FOO_STATIC: FooStruct = FooStruct;
extern "C" {
// @matches 'foo/static.FOO_FSTATIC.html' '//h1' 'Static foo::FOO_FSTATIC'
... | random_line_split | |
titles.rs | #![crate_name = "foo"]
// @matches 'foo/index.html' '//h1' 'Crate foo'
// @matches 'foo/foo_mod/index.html' '//h1' 'Module foo::foo_mod'
pub mod foo_mod {
pub struct | {}
}
extern "C" {
// @matches 'foo/fn.foo_ffn.html' '//h1' 'Function foo::foo_ffn'
pub fn foo_ffn();
}
// @matches 'foo/fn.foo_fn.html' '//h1' 'Function foo::foo_fn'
pub fn foo_fn() {}
// @matches 'foo/trait.FooTrait.html' '//h1' 'Trait foo::FooTrait'
pub trait FooTrait {}
// @matches 'foo/struct.FooStruct... | __Thing | identifier_name |
v1.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 ... | {
#[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
pub fill: char,
#[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
pub align: Alignment,
#[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
pub flags: u32,
#[cfg_attr(stage0, stable(feature = "rust1"... | FormatSpec | identifier_name |
v1.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 ... | /// Indication that contents should be right-aligned.
#[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
Right,
/// Indication that contents should be center-aligned.
#[cfg_attr(stage0, stable(feature = "rust1", since = "1.0.0"))]
Center,
/// No alignment was requested.
#[cf... | Left, | random_line_split |
htmlformelement.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::HTMLFormElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLFormEl... | {
pub htmlelement: HTMLElement
}
impl HTMLFormElementDerived for EventTarget {
fn is_htmlformelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLFormElementTypeId))
}
}
impl HTMLFormElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> ... | HTMLFormElement | identifier_name |
htmlformelement.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::HTMLFormElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLFormEl... |
#[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLFormElement> {
let element = HTMLFormElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLFormElementBinding::Wrap)
}
}
impl Reflectable for HTMLF... | pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLFormElement {
HTMLFormElement {
htmlelement: HTMLElement::new_inherited(HTMLFormElementTypeId, localName, document)
}
} | random_line_split |
htmlformelement.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::HTMLFormElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLFormEl... |
}
impl HTMLFormElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLFormElement {
HTMLFormElement {
htmlelement: HTMLElement::new_inherited(HTMLFormElementTypeId, localName, document)
}
}
#[allow(unrooted_must_root)]
pub fn new(localName: ... | {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLFormElementTypeId))
} | identifier_body |
load_info.rs | use crate::errors::*;
use crate::filesystem::readers::ExtraReader;
use crate::filesystem::FileSystem;
use crate::filesystem::Translator;
use crate::kernel::execve::binfmt::elf::{ElfHeader, ExecutableClass, ProgramHeader};
use crate::kernel::execve::binfmt::elf::{PF_R, PF_W, PF_X, PT_GNU_STACK, PT_INTERP, PT_LOAD};
use ... | () {
let rootfs_path = get_test_rootfs_path();
let fs = FileSystem::with_root(rootfs_path).unwrap();
let result = LoadInfo::from(&fs, &PathBuf::from("/../../.."));
assert!(result.is_err());
assert_eq!(Error::errno(EISDIR), result.unwrap_err());
}
#[test]
fn test_lo... | test_load_info_from_invalid_path | identifier_name |
load_info.rs | use crate::errors::*;
use crate::filesystem::readers::ExtraReader;
use crate::filesystem::FileSystem;
use crate::filesystem::Translator;
use crate::kernel::execve::binfmt::elf::{ElfHeader, ExecutableClass, ProgramHeader};
use crate::kernel::execve::binfmt::elf::{PF_R, PF_W, PF_X, PT_GNU_STACK, PT_INTERP, PT_LOAD};
use ... | pub needs_executable_stack: bool,
}
lazy_static! {
static ref PAGE_SIZE: Word = match sysconf(SysconfVar::PAGE_SIZE) {
Ok(Some(value)) => value as Word,
_ => 0x1000,
};
static ref PAGE_MASK: Word =!(*PAGE_SIZE - 1);
}
//TODO: move these in arch.rs and do cfg for each env
#[cfg(target_a... | pub mappings: Vec<Mapping>,
pub interp: Option<Box<LoadInfo>>, | random_line_split |
load_info.rs | use crate::errors::*;
use crate::filesystem::readers::ExtraReader;
use crate::filesystem::FileSystem;
use crate::filesystem::Translator;
use crate::kernel::execve::binfmt::elf::{ElfHeader, ExecutableClass, ProgramHeader};
use crate::kernel::execve::binfmt::elf::{PF_R, PF_W, PF_X, PT_GNU_STACK, PT_INTERP, PT_LOAD};
use ... |
#[inline]
fn process_prot_flags(flags: u32) -> ProtFlags {
let read_flag = process_flag(flags, PF_R, ProtFlags::PROT_READ, ProtFlags::PROT_NONE);
let write_flag = process_flag(flags, PF_W, ProtFlags::PROT_WRITE, ProtFlags::PROT_NONE);
let execute_flag = process_flag(flags, PF_X, ProtFlags::PROT_EXEC, Prot... | {
if flags & compare_flag > 0 {
success_flag
} else {
default_flag
}
} | identifier_body |
emitter.rs | //! An emitter is an instance of geometry that both receives and emits light
//!
//! # Scene Usage Example
//! An emitter is an object in the scene that emits light, it can be a point light
//! or an area light. The emitter takes an extra 'emitter' parameter to specify
//! whether the instance is an area or point emitt... | (&self) -> bool {
match &self.emitter {
&EmitterType::Point => true,
_ => false,
}
}
fn pdf(&self, p: &Point, w_i: &Vector) -> f32 {
match &self.emitter {
&EmitterType::Point => 0.0,
&EmitterType::Area(ref g, _ ) => {
let p... | delta_light | identifier_name |
emitter.rs | //! An emitter is an instance of geometry that both receives and emits light
//!
//! # Scene Usage Example
//! An emitter is an object in the scene that emits light, it can be a point light
//! or an area light. The emitter takes an extra 'emitter' parameter to specify
//! whether the instance is an area or point emitt... | let w = (self.transform.inv_mul_vector(w_i)).normalized();
g.pdf(&p_l, &w)
}
}
}
} | let p_l = self.transform.inv_mul_point(p); | random_line_split |
emitter.rs | //! An emitter is an instance of geometry that both receives and emits light
//!
//! # Scene Usage Example
//! An emitter is an object in the scene that emits light, it can be a point light
//! or an area light. The emitter takes an extra 'emitter' parameter to specify
//! whether the instance is an area or point emitt... |
}
impl Light for Emitter {
fn sample_incident(&self, p: &Point, samples: &(f32, f32))
-> (Colorf, Vector, f32, OcclusionTester)
{
match &self.emitter {
&EmitterType::Point => {
let pos = self.transform * Point::broadcast(0.0);
let w_i = (pos - *p).no... | {
match &self.emitter {
&EmitterType::Point => BBox::singular(self.transform * Point::broadcast(0.0)),
&EmitterType::Area(ref g, _) => {
self.transform * g.bounds()
},
}
} | identifier_body |
receive_as_stream.rs | // Copyright 2019 Google LLC
//
// 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
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in ... |
fn _poll_next_unpin(&mut self, cx: &mut Context<'_>) -> Poll<Option<Result<(), Error>>> {
if let Some(recv_future) = self.recv_future.as_mut() {
match recv_future.poll_unpin(cx) {
Poll::Ready(Err(Error::IOError)) => {
self.recv_future = None;
... | {
self.recv_future = Some(self.local_endpoint.receive(self.handler.clone()));
} | identifier_body |
receive_as_stream.rs | // Copyright 2019 Google LLC
//
// 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
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in ... | } | type Item = Result<(), Error>;
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
self.get_mut()._poll_next_unpin(cx)
} | random_line_split |
receive_as_stream.rs | // Copyright 2019 Google LLC
//
// 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
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in ... | (local_endpoint: &'a LE, handler: F) -> ReceiveAsStream<'a, LE, F> {
let mut ret = ReceiveAsStream {
local_endpoint,
recv_future: None,
handler,
};
ret.update_recv_future();
return ret;
}
fn update_recv_future(&mut self) {
self.recv_fu... | new | identifier_name |
eo_view.rs |
// std imports
use std::mem;
// external imports
use num::traits::Num;
// local imports
use algebra::structure::MagmaBase;
use super::eo_traits::{ERO, ECO};
use matrix::view::MatrixView;
use matrix::traits::{Shape, MatrixBuffer, Strided};
/// Implementation of Elementary row operations.
impl<'a, T:MagmaBase + Nu... | (&mut self,
i : usize,
j : isize,
scale : T
)-> &mut MatrixView<'a, T> {
debug_assert! (i < self.num_cols());
let m = self.matrix();
// Compute j-th column in m (by doing offset)
let j = j + (self.start_col() as isize);
debug_assert! (j >= 0... | eco_scale_add | identifier_name |
eo_view.rs |
// std imports
use std::mem;
// external imports
use num::traits::Num;
// local imports
use algebra::structure::MagmaBase;
use super::eo_traits::{ERO, ECO};
use matrix::view::MatrixView;
use matrix::traits::{Shape, MatrixBuffer, Strided};
/// Implementation of Elementary row operations.
impl<'a, T:MagmaBase + Nu... | }
// Update offsets
offset_a += 1;
offset_b += 1;
}
self
}
}
/******************************************************
*
* Unit tests
*
*******************************************************/
#[cfg(test)]
mod test{
//use super::*;
}
/*... | {
debug_assert! (i < self.num_cols());
let m = self.matrix();
// Compute j-th column in m (by doing offset)
let j = j + (self.start_col() as isize);
debug_assert! (j >= 0);
let j = j as usize;
debug_assert!(j < m.num_cols());
let ptr = m.as_ptr();
... | identifier_body |
eo_view.rs | // std imports
use std::mem;
// external imports
use num::traits::Num;
| // local imports
use algebra::structure::MagmaBase;
use super::eo_traits::{ERO, ECO};
use matrix::view::MatrixView;
use matrix::traits::{Shape, MatrixBuffer, Strided};
/// Implementation of Elementary row operations.
impl<'a, T:MagmaBase + Num> ERO<T> for MatrixView<'a, T> {
/// Row scaling by a factor and addi... | random_line_split | |
borrowck-lend-flow.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 ... |
fn produce<T>() -> T { panic!(); }
fn inc(v: &mut Box<isize>) {
*v = box (**v + 1);
}
fn pre_freeze() {
// In this instance, the freeze starts before the mut borrow.
let mut v: Box<_> = box 3;
let _w = &v;
borrow_mut(&mut *v); //~ ERROR cannot borrow
_w.use_ref();
}
fn post_freeze() {
/... | { panic!() } | identifier_body |
borrowck-lend-flow.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 ... | () {
// In this instance, the const alias starts after the borrow.
let mut v: Box<_> = box 3;
borrow_mut(&mut *v);
let _w = &v;
}
fn main() {}
trait Fake { fn use_mut(&mut self) { } fn use_ref(&self) { } }
impl<T> Fake for T { }
| post_freeze | identifier_name |
borrowck-lend-flow.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 ... | // either genuine or would require more advanced changes. The latter
// cases are noted.
#![feature(box_syntax)]
fn borrow(_v: &isize) {}
fn borrow_mut(_v: &mut isize) {}
fn cond() -> bool { panic!() }
fn for_func<F>(_f: F) where F: FnOnce() -> bool { panic!() }
fn produce<T>() -> T { panic!(); }
fn inc(v: &mut Box... | random_line_split | |
utils.rs | //! Various utilities
/*
use std::old_io::net::ip;
/// Convert socket address to bytes in network order.
pub fn netaddr_to_netbytes(addr: &ip::SocketAddr) -> Vec<u8> {
match addr.ip {
ip::Ipv4Addr(a, b, c, d) =>
vec![a, b, c, d, (addr.port >> 8) as u8, (addr.port & 0xFF) as u8],
// TOD... | (id: usize) -> num::BigUint {
FromPrimitive::from_usize(id).unwrap()
}
}
| usize_to_id | identifier_name |
utils.rs | //! Various utilities
/*
use std::old_io::net::ip;
/// Convert socket address to bytes in network order.
pub fn netaddr_to_netbytes(addr: &ip::SocketAddr) -> Vec<u8> {
match addr.ip {
ip::Ipv4Addr(a, b, c, d) =>
vec![a, b, c, d, (addr.port >> 8) as u8, (addr.port & 0xFF) as u8],
// TOD... |
pub fn new_node_with_port(id: usize, port: u16) -> Node {
Node {
id: FromPrimitive::from_usize(id).unwrap(),
address: SocketAddr::V4( SocketAddrV4::new(
Ipv4Addr::new(127, 0, 0, 1),
port
) )
}
}
pub fn usize_to_id(id: us... | {
new_node_with_port(id, 8008)
} | identifier_body |
utils.rs | //! Various utilities
/*
use std::old_io::net::ip;
/// Convert socket address to bytes in network order.
pub fn netaddr_to_netbytes(addr: &ip::SocketAddr) -> Vec<u8> {
match addr.ip {
ip::Ipv4Addr(a, b, c, d) =>
vec![a, b, c, d, (addr.port >> 8) as u8, (addr.port & 0xFF) as u8],
// TOD... | use num::traits::FromPrimitive;
use num;
use super::super::Node;
pub static ADDR: &'static str = "127.0.0.1:8008";
pub fn new_node(id: usize) -> Node {
new_node_with_port(id, 8008)
}
pub fn new_node_with_port(id: usize, port: u16) -> Node {
Node {
id: FromPr... | #[cfg(test)]
pub mod test {
use std::net::SocketAddr;
use std::net::SocketAddrV4;
use std::net::Ipv4Addr; | random_line_split |
htmlbrelement.rs |
use dom::bindings::codegen::Bindings::HTMLBRElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLBRElementDerived;
use dom::bindings::js::Root;
use dom::document::Document;
use dom::element::ElementTypeId;
use dom::eventtarget::{EventTarget, EventTargetTypeId};
use dom::htmlelement::{HTMLElement, HTMLElementT... | /* 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/. */ | random_line_split | |
htmlbrelement.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::HTMLBRElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLBRElemen... |
}
| {
let element = HTMLBRElement::new_inherited(localName, prefix, document);
Node::reflect_node(box element, document, HTMLBRElementBinding::Wrap)
} | identifier_body |
htmlbrelement.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::HTMLBRElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLBRElemen... | {
htmlelement: HTMLElement,
}
impl HTMLBRElementDerived for EventTarget {
fn is_htmlbrelement(&self) -> bool {
*self.type_id() ==
EventTargetTypeId::Node(
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLBRElement)))
}
}
impl HTMLBRElement {
fn... | HTMLBRElement | identifier_name |
issue-11709.rs | // Copyright 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-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// ignore-pretty
/... | random_line_split | |
issue-11709.rs | // Copyright 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-MIT or ... | {x:()}
fn test(slot: &mut Option<Thunk<(),Thunk>>) -> () {
let a = slot.take();
let _a = match a {
// `{let.. a(); }` would break
Some(a) => { let _a = a(); },
None => (),
};
}
fn not(b: bool) -> bool {
if b {
!b
} else {
// `panic!(...)` would break
panic!("Break the... | S | identifier_name |
rcdom.rs | // Copyright 2014 The html5ever Project Developers. See the
// COPYRIGHT file at the top-level directory of this distribution.
//
// 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 http://opensource.org/licenses/MIT>,... | for handle in node.children.iter() {
try!(handle.clone().serialize(serializer, IncludeNode));
}
Ok(())
}
(ChildrenOnly, _) => Ok(()),
(IncludeNode, &Doctype(ref name, _, _)) => serializer.write_doctype(&name),
... | {
let node = self.borrow();
match (traversal_scope, &node.node) {
(_, &Element(ref name, _, ref attrs)) => {
if traversal_scope == IncludeNode {
try!(serializer.start_elem(name.clone(),
attrs.iter().map(|at| (&at.name, &at.value[..]... | identifier_body |
rcdom.rs | // Copyright 2014 The html5ever Project Developers. See the
// COPYRIGHT file at the top-level directory of this distribution.
//
// 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 http://opensource.org/licenses/MIT>,... | pub children: Vec<Handle>,
}
impl Node {
fn new(node: NodeEnum) -> Node {
Node {
node: node,
parent: None,
children: vec!(),
}
}
}
/// Reference to a DOM node.
#[derive(Clone, Debug)]
pub struct Handle(Rc<RefCell<Node>>);
impl Deref for Handle {
typ... | #[derive(Debug)]
pub struct Node {
pub node: NodeEnum,
pub parent: Option<WeakHandle>, | random_line_split |
rcdom.rs | // Copyright 2014 The html5ever Project Developers. See the
// COPYRIGHT file at the top-level directory of this distribution.
//
// 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 http://opensource.org/licenses/MIT>,... | (Rc<RefCell<Node>>);
impl Deref for Handle {
type Target = Rc<RefCell<Node>>;
fn deref(&self) -> &Rc<RefCell<Node>> { &self.0 }
}
/// Weak reference to a DOM node, used for parent pointers.
pub type WeakHandle = Weak<RefCell<Node>>;
#[allow(trivial_casts)]
fn same_node(x: &Handle, y: &Handle) -> bool {
/... | Handle | identifier_name |
main.rs | extern crate time;
use time::Duration;
fn main() {
let duration = Duration::span(|| {
let n: i32 = 10000000;
let mut h: Vec<i32> = (0..n).collect();
make_heap(&mut *h);
for i in (1..n as usize).rev() {
h.swap(0, i);
push_down(0, i, &mut *h);
}
... |
if h[pos] > h[vic] {
break;
}
h.swap(pos, vic);
pos = vic;
}
}
| {
vic += 1;
} | conditional_block |
main.rs | extern crate time;
use time::Duration;
fn main() {
let duration = Duration::span(|| {
let n: i32 = 10000000;
let mut h: Vec<i32> = (0..n).collect();
make_heap(&mut *h);
for i in (1..n as usize).rev() {
h.swap(0, i);
push_down(0, i, &mut *h);
}
... | }
fn make_heap(h: &mut [i32]) {
for i in (0..h.len() / 2).rev() {
push_down(i, h.len(), h);
}
}
fn push_down(mut pos: usize, size: usize, h: &mut [i32]) {
while 2 * pos + 1 < size {
let mut vic = 2 * pos + 1;
if vic + 1 < size && h[vic + 1] > h[vic] {
vic += 1;
... | random_line_split | |
main.rs | extern crate time;
use time::Duration;
fn main() {
let duration = Duration::span(|| {
let n: i32 = 10000000;
let mut h: Vec<i32> = (0..n).collect();
make_heap(&mut *h);
for i in (1..n as usize).rev() {
h.swap(0, i);
push_down(0, i, &mut *h);
}
... |
fn push_down(mut pos: usize, size: usize, h: &mut [i32]) {
while 2 * pos + 1 < size {
let mut vic = 2 * pos + 1;
if vic + 1 < size && h[vic + 1] > h[vic] {
vic += 1;
}
if h[pos] > h[vic] {
break;
}
h.swap(pos, vic);
pos = vic;
}... | {
for i in (0..h.len() / 2).rev() {
push_down(i, h.len(), h);
}
} | identifier_body |
main.rs | extern crate time;
use time::Duration;
fn main() {
let duration = Duration::span(|| {
let n: i32 = 10000000;
let mut h: Vec<i32> = (0..n).collect();
make_heap(&mut *h);
for i in (1..n as usize).rev() {
h.swap(0, i);
push_down(0, i, &mut *h);
}
... | (h: &mut [i32]) {
for i in (0..h.len() / 2).rev() {
push_down(i, h.len(), h);
}
}
fn push_down(mut pos: usize, size: usize, h: &mut [i32]) {
while 2 * pos + 1 < size {
let mut vic = 2 * pos + 1;
if vic + 1 < size && h[vic + 1] > h[vic] {
vic += 1;
}
if h... | make_heap | identifier_name |
issue-5688.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 ... | {
for &v in V.iter() {
println!("{}", v.vec);
}
} | identifier_body | |
issue-5688.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 ... | for &v in V.iter() {
println!("{}", v.vec);
}
} |
struct X { vec: &'static [int] }
static V: &'static [X] = &[X { vec: &[1, 2, 3] }];
pub fn main() { | random_line_split |
issue-5688.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 ... | () {
for &v in V.iter() {
println!("{}", v.vec);
}
}
| main | identifier_name |
buffer.rs | use std::iter::FromIterator;
use std::io::{
BufRead,
Write
};
use std::vec::IntoIter;
use std::ops;
use Result;
#[derive(Debug)]
pub struct Buffer {
lines: Vec<String>,
cached_num_lines: usize,
modified: bool
}
trait InsertAll {
type Item;
fn insert_all<I: IntoIterator<Item=Self::Item>>... | self.is_out_of_bounds(range.start) || self.is_out_of_bounds(range.end)
}
pub fn get_lines(&self, range: &ops::Range<usize>) -> &[String] {
assert!(! self.is_out_of_bounds( range.start ), format!("Out of bounds: {}/0", range.start) );
assert!(! self.is_out_of_bounds( range.end ), format!... | }
pub fn is_range_out_of_bounds(&self, range: &ops::Range<usize>) -> bool { | random_line_split |
buffer.rs |
use std::iter::FromIterator;
use std::io::{
BufRead,
Write
};
use std::vec::IntoIter;
use std::ops;
use Result;
#[derive(Debug)]
pub struct Buffer {
lines: Vec<String>,
cached_num_lines: usize,
modified: bool
}
trait InsertAll {
type Item;
fn insert_all<I: IntoIterator<Item=Self::Item>... | <R: BufRead + Sized> (buf_read: R) -> Result<Buffer> {
let lines = buf_read.lines();
let lines_vec = lines.map(|r| r.unwrap()).collect::<Vec<String>>();
let cached_len = lines_vec.len();
Ok(Buffer {
lines: lines_vec,
cached_num_lines: cached_len,
mo... | from_buf_read | identifier_name |
buffer.rs |
use std::iter::FromIterator;
use std::io::{
BufRead,
Write
};
use std::vec::IntoIter;
use std::ops;
use Result;
#[derive(Debug)]
pub struct Buffer {
lines: Vec<String>,
cached_num_lines: usize,
modified: bool
}
trait InsertAll {
type Item;
fn insert_all<I: IntoIterator<Item=Self::Item>... |
pub fn get_lines(&self, range: &ops::Range<usize>) -> &[String] {
assert!(! self.is_out_of_bounds( range.start ), format!("Out of bounds: {}/0", range.start) );
assert!(! self.is_out_of_bounds( range.end ), format!("Out of bounds: {}/{}", range.end, self.len()) );
&self.lines[ range.star... | {
self.is_out_of_bounds(range.start) || self.is_out_of_bounds(range.end)
} | identifier_body |
float_macros.rs | // Copyright 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-MIT or ... | }
// If we are not yet at the exponent parse the fractional
// part of the significand
if exp_info.is_none() {
let mut power = 1.0;
for (i, c) in cs.by_ref() {
match c.to_digit(radix) {
Some(digi... | },
},
} | random_line_split |
htmltablecellelement.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 cssparser::RGBA;
use dom::attr::{Attr, AttrValue};
use dom::bindings::codegen::Bindings::HTMLTableCellElementB... | (&self) -> Option<u32> {
unsafe {
(&*self.upcast::<Element>().unsafe_get())
.get_attr_for_layout(&ns!(), &atom!("colspan"))
.map(AttrValue::as_uint)
}
}
fn get_width(&self) -> LengthOrPercentageOrAuto {
unsafe {
(*self.unsafe_get()).... | get_colspan | identifier_name |
htmltablecellelement.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 cssparser::RGBA;
use dom::attr::{Attr, AttrValue};
use dom::bindings::codegen::Bindings::HTMLTableCellElementB... |
}
pub trait HTMLTableCellElementLayoutHelpers {
fn get_background_color(&self) -> Option<RGBA>;
fn get_colspan(&self) -> Option<u32>;
fn get_width(&self) -> LengthOrPercentageOrAuto;
}
#[allow(unsafe_code)]
impl HTMLTableCellElementLayoutHelpers for LayoutJS<HTMLTableCellElement> {
fn get_background... | {
let self_node = self.upcast::<Node>();
let parent_children = match self_node.GetParentNode() {
Some(ref parent_node) if parent_node.is::<HTMLTableRowElement>() => {
parent_node.children()
},
_ => return -1,
};
parent_children.filter... | identifier_body |
htmltablecellelement.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 cssparser::RGBA;
use dom::attr::{Attr, AttrValue};
use dom::bindings::codegen::Bindings::HTMLTableCellElementB... | match *attr.local_name() {
atom!("width") => {
let width = mutation.new_value(attr).map(|value| {
str::parse_length(&value)
});
self.width.set(width.unwrap_or(LengthOrPercentageOrAuto::Auto));
},
_ => {},
... | self.super_type().unwrap().attribute_mutated(attr, mutation); | random_line_split |
issue-1112.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 ... | <T>(x: X<T>) {
assert_eq!(x.b, 9);
assert_eq!(x.c, true);
assert_eq!(x.d, 10);
assert_eq!(x.e, 11);
assert_eq!(x.f, 12);
assert_eq!(x.g, 13);
}
| bar | identifier_name |
issue-1112.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 ... | assert_eq!(x.e, 11);
assert_eq!(x.f, 12);
assert_eq!(x.g, 13);
} |
fn bar<T>(x: X<T>) {
assert_eq!(x.b, 9);
assert_eq!(x.c, true);
assert_eq!(x.d, 10); | random_line_split |
inherit-struct2.rs | // Copyright 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-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Test struct inhe... | random_line_split | |
inherit-struct2.rs | // Copyright 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-MIT or ... | {
let s = inherit_struct_lib::S2{f1: 115, f2: 113};
assert!(s.f1 == 115);
assert!(s.f2 == 113);
assert!(inherit_struct_lib::glob_s.f1 == 32);
assert!(inherit_struct_lib::glob_s.f2 == -45);
inherit_struct_lib::test_s2(s);
} | identifier_body | |
inherit-struct2.rs | // Copyright 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-MIT or ... | () {
let s = inherit_struct_lib::S2{f1: 115, f2: 113};
assert!(s.f1 == 115);
assert!(s.f2 == 113);
assert!(inherit_struct_lib::glob_s.f1 == 32);
assert!(inherit_struct_lib::glob_s.f2 == -45);
inherit_struct_lib::test_s2(s);
}
| main | identifier_name |
server.rs | #![feature(core)]
extern crate eve;
extern crate getopts;
extern crate url;
extern crate core;
use std::thread;
use std::env;
use getopts::Options;
use std::net::SocketAddr;
use core::str::FromStr;
use eve::server;
use eve::login;
#[allow(dead_code)]
fn main() { |
// handle command line arguments
let args: Vec<String> = env::args().collect();
// define the command line arguments
let mut opts = Options::new();
opts.optopt("f", "faddress", "specify a socket address for the static file server. Defaults to 0.0.0.0:8080","SOCKET ADDRESS");
opts.optflag("h", "help", "pri... | random_line_split | |
server.rs | #![feature(core)]
extern crate eve;
extern crate getopts;
extern crate url;
extern crate core;
use std::thread;
use std::env;
use getopts::Options;
use std::net::SocketAddr;
use core::str::FromStr;
use eve::server;
use eve::login;
#[allow(dead_code)]
fn main() | }
// parse static file server address
let default_addr= SocketAddr::from_str("0.0.0.0:8080").unwrap();
let addr = match matches.opt_str("f") {
Some(ip) => {
match SocketAddr::from_str(&*ip) {
Ok(addr) => addr,
Err(_) => {
println!("WARNING: Could not parse static file ser... | {
// handle command line arguments
let args: Vec<String> = env::args().collect();
// define the command line arguments
let mut opts = Options::new();
opts.optopt("f", "faddress", "specify a socket address for the static file server. Defaults to 0.0.0.0:8080","SOCKET ADDRESS");
opts.optflag("h", "help", "p... | identifier_body |
server.rs | #![feature(core)]
extern crate eve;
extern crate getopts;
extern crate url;
extern crate core;
use std::thread;
use std::env;
use getopts::Options;
use std::net::SocketAddr;
use core::str::FromStr;
use eve::server;
use eve::login;
#[allow(dead_code)]
fn | () {
// handle command line arguments
let args: Vec<String> = env::args().collect();
// define the command line arguments
let mut opts = Options::new();
opts.optopt("f", "faddress", "specify a socket address for the static file server. Defaults to 0.0.0.0:8080","SOCKET ADDRESS");
opts.optflag("h", "help",... | main | identifier_name |
irq.rs | use ::kern::arch::port::{UnsafePort, Port};
use spin::Mutex;
/**
* ref: http://wiki.osdev.org/8259_PIC
*/
const PIC1_BASE: u16 = 0x20; /* IO base address for master PIC */
const PIC2_BASE: u16 = 0xA0; /* IO base address for slave PIC */
// Initial IRQ mask has interrupt 2 enabled (for slave 8259A).
const IRQ_MASK: u... |
self.pics[1].command.write(ICW1_INIT + ICW1_ICW4);
io_wait();
self.pics[0].data.write(self.pics[0].offset);
io_wait();
self.pics[1].data.write(self.pics[1].offset);
io_wait();
// ICW3: tell Master PIC that there is a slave PIC at IRQ2
self.pics[0].data.... |
self.pics[0].command.write(ICW1_INIT + ICW1_ICW4);
io_wait(); | random_line_split |
irq.rs | use ::kern::arch::port::{UnsafePort, Port};
use spin::Mutex;
/**
* ref: http://wiki.osdev.org/8259_PIC
*/
const PIC1_BASE: u16 = 0x20; /* IO base address for master PIC */
const PIC2_BASE: u16 = 0xA0; /* IO base address for slave PIC */
// Initial IRQ mask has interrupt 2 enabled (for slave 8259A).
const IRQ_MASK: u... |
self.pics[0].eoi();
}
unsafe fn setmask(&mut self, mask: u16) {
self.irqmask = mask;
self.pics[0].data.write(mask as u8);
self.pics[1].data.write((mask >> 8) as u8);
}
pub unsafe fn enable(&mut self, irq: usize) {
assert!(irq >= 0x20 && irq < 0x30);
le... | {
self.pics[1].eoi();
} | conditional_block |
irq.rs | use ::kern::arch::port::{UnsafePort, Port};
use spin::Mutex;
/**
* ref: http://wiki.osdev.org/8259_PIC
*/
const PIC1_BASE: u16 = 0x20; /* IO base address for master PIC */
const PIC2_BASE: u16 = 0xA0; /* IO base address for slave PIC */
// Initial IRQ mask has interrupt 2 enabled (for slave 8259A).
const IRQ_MASK: u... |
}
/// represent two cascaded pic chips
pub struct PicChain {
pics: [Pic8259A; 2],
irqmask: u16
}
pub static PIC_CHAIN: Mutex<PicChain> = Mutex::new(unsafe {PicChain::new()});
/* reinitialize the PIC controllers, giving them specified vector offsets
rather than 8h and 70h, as configured by default */
co... | {
self.command.write(0x20);
} | identifier_body |
irq.rs | use ::kern::arch::port::{UnsafePort, Port};
use spin::Mutex;
/**
* ref: http://wiki.osdev.org/8259_PIC
*/
const PIC1_BASE: u16 = 0x20; /* IO base address for master PIC */
const PIC2_BASE: u16 = 0xA0; /* IO base address for slave PIC */
// Initial IRQ mask has interrupt 2 enabled (for slave 8259A).
const IRQ_MASK: u... | {
offset: u8,
command: UnsafePort<u8>,
data: UnsafePort<u8>
}
impl Pic8259A {
pub const unsafe fn new(base: u16, offset: u8) -> Pic8259A {
Pic8259A {
offset: offset,
command: UnsafePort::new(base),
data: UnsafePort::new(base+1)
}
}
pub unsa... | Pic8259A | identifier_name |
table_caption.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/. */
//! CSS table formatting contexts.
use app_units::Au;
use block::BlockFlow;
use context::LayoutContext;
use displ... |
fn compute_overflow(&self) -> Overflow {
self.block_flow.compute_overflow()
}
fn contains_roots_of_absolute_flow_tree(&self) -> bool {
self.block_flow.contains_roots_of_absolute_flow_tree()
}
fn is_absolute_containing_block(&self) -> bool {
self.block_flow.is_absolute_con... | {
self.block_flow.repair_style(new_style)
} | identifier_body |
table_caption.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/. */
//! CSS table formatting contexts.
use app_units::Au;
use block::BlockFlow;
use context::LayoutContext;
use displ... | }
fn is_absolute_containing_block(&self) -> bool {
self.block_flow.is_absolute_containing_block()
}
fn generated_containing_block_size(&self, flow: OpaqueFlow) -> LogicalSize<Au> {
self.block_flow.generated_containing_block_size(flow)
}
fn iterate_through_fragment_border_boxes... | random_line_split | |
table_caption.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/. */
//! CSS table formatting contexts.
use app_units::Au;
use block::BlockFlow;
use context::LayoutContext;
use displ... | (&self, print_tree: &mut PrintTree) {
self.block_flow.print_extra_flow_children(print_tree);
}
}
impl fmt::Debug for TableCaptionFlow {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "TableCaptionFlow: {:?}", self.block_flow)
}
}
| print_extra_flow_children | identifier_name |
coherence-overlap-downstream.rs | // Copyright 2017 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 ... | { } | identifier_body | |
coherence-overlap-downstream.rs | // Copyright 2017 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 |
coherence-overlap-downstream.rs | // Copyright 2017 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 trait Sugar {}
pub trait Fruit {}
pub trait Sweet {}
impl<T:Sugar> Sweet for T { }
impl<T:Fruit> Sweet for T { }
//~^ ERROR E0119
pub trait Foo<X> {}
pub trait Bar<X> {}
impl<X, T> Foo<X> for T where T: Bar<X> {}
impl<X> Foo<X> for i32 {}
//~^ ERROR E0119
fn main() { } | // though no impls are found. | random_line_split |
lib.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 ... | )
}
add_builtin!(sess,
HardwiredLints,
WhileTrue,
ImproperCTypes,
BoxPointers,
UnusedAttributes,
PathStatements,
UnusedResults,
NonCamelCaseTypes,
... | {
macro_rules! add_builtin {
($sess:ident, $($name:ident),*,) => (
{$(
store.register_pass($sess, false, box builtin::$name);
)*}
)
}
macro_rules! add_builtin_with_new {
($sess:ident, $($name:ident),*,) => (
{$(
... | identifier_body |
lib.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 ... | (store: &mut lint::LintStore, sess: Option<&Session>) {
macro_rules! add_builtin {
($sess:ident, $($name:ident),*,) => (
{$(
store.register_pass($sess, false, box builtin::$name);
)*}
)
}
macro_rules! add_builtin_with_new {
($sess:iden... | register_builtins | identifier_name |
lib.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 ... |
add_builtin!(sess,
HardwiredLints,
WhileTrue,
ImproperCTypes,
BoxPointers,
UnusedAttributes,
PathStatements,
UnusedResults,
NonCamelCaseTypes,
NonSnakeCase,
... | ($sess:ident, $name:expr, $($lint:ident),*) => (
store.register_group($sess, false, $name, vec![$(LintId::of(builtin::$lint)),*]);
)
} | random_line_split |
multiple_files.rs | // Copyright 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-MIT or ... |
fn main() {
let args: Vec<String> = env::args().collect();
let rustc = &args[1];
let tmpdir = Path::new(&args[2]);
let main_file = tmpdir.join("unicode_input_multiple_files_main.rs");
{
let _ = File::create(&main_file).unwrap()
.write_all(b"mod unicode_input_multiple_files_char... | {
let mut rng = thread_rng();
// a subset of the XID_start Unicode table (ensuring that the
// compiler doesn't fail with an "unrecognised token" error)
let (lo, hi): (u32, u32) = match rng.gen_range(1u32, 4u32 + 1) {
1 => (0x41, 0x5a),
2 => (0xf8, 0x1ba),
3 => (0x1401, 0x166c),
... | identifier_body |
multiple_files.rs | // Copyright 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-MIT or ... | let rustc = &args[1];
let tmpdir = Path::new(&args[2]);
let main_file = tmpdir.join("unicode_input_multiple_files_main.rs");
{
let _ = File::create(&main_file).unwrap()
.write_all(b"mod unicode_input_multiple_files_chars;").unwrap();
}
for _ in 0..100 {
{
... | }
fn main() {
let args: Vec<String> = env::args().collect(); | random_line_split |
multiple_files.rs | // Copyright 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-MIT or ... | () {
let args: Vec<String> = env::args().collect();
let rustc = &args[1];
let tmpdir = Path::new(&args[2]);
let main_file = tmpdir.join("unicode_input_multiple_files_main.rs");
{
let _ = File::create(&main_file).unwrap()
.write_all(b"mod unicode_input_multiple_files_chars;").unwr... | main | identifier_name |
traffic.rs | use std::env;
use tokio::runtime::Runtime;
use hubcaps::traffic::TimeUnit;
use hubcaps::{Credentials, Github, Result};
fn | () -> Result<()> {
pretty_env_logger::init();
match env::var("GITHUB_TOKEN").ok() {
Some(token) => {
let mut rt = Runtime::new()?;
let github = Github::new(
concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION")),
Credentials::Token(token),... | main | identifier_name |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.