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 |
|---|---|---|---|---|
build.rs | use std::path::Path;
use std::path::PathBuf;
use std::env;
use std::process::Command;
fn main() {
let out_dir = env::var("OUT_DIR").unwrap();
let target = env::var("TARGET").unwrap();
// http://doc.crates.io/build-script.html#inputs-to-the-build-script
// "the build script’s current directory is the ... | let qt_dir_default = home_dir.join("Qt")
.join(env::var("QT_VER").unwrap_or(default_qt_ver))
.join(env::var("QT_COMP").unwrap_or(default_qt_comp));
qt_dir_default
});
println!("Using Qt directory: {:?}", qt_dir);
println!("Use... | println!(" QT_COMP: {}", default_qt_comp); | random_line_split |
build.rs | use std::path::Path;
use std::path::PathBuf;
use std::env;
use std::process::Command;
fn main() {
let out_dir = env::var("OUT_DIR").unwrap();
let target = env::var("TARGET").unwrap();
// http://doc.crates.io/build-script.html#inputs-to-the-build-script
// "the build script’s current directory is the ... | e {
panic!("Unsuported platform in gallery's build.rs!")
};
println!(" QT_VER: {}", default_qt_ver);
println!(" QT_COMP: {}", default_qt_comp);
let qt_dir_default = home_dir.join("Qt")
.join(env::var("QT_VER").unwrap_or(default_qt_ver))... | "clang_64".to_string()
} els | conditional_block |
tokens.rs | use std::collections::HashMap;
pub use self::Block::*;
pub use self::Inline::*;
pub type Document = Vec<Block>;
pub type Text = Vec<Inline>;
pub type LinkMap = HashMap<String, LinkDescription>;
pub struct LinkDescription {
pub id: String,
pub link: String,
pub title: Option<String>
}
#[derive(PartialE... | }
}
}
| {
match *self {
Emphasis(ref mut content) | MoreEmphasis(ref mut content) =>
content.fix_links(link_map),
Link { ref mut link, ref mut title, id: Some(ref id), .. } => {
match link_map.get(id) {
Some(ld) => {
if... | identifier_body |
tokens.rs | use std::collections::HashMap;
pub use self::Block::*;
pub use self::Inline::*;
pub type Document = Vec<Block>;
pub type Text = Vec<Inline>;
pub type LinkMap = HashMap<String, LinkDescription>;
pub struct LinkDescription {
pub id: String,
pub link: String,
pub title: Option<String>
}
#[derive(PartialE... | OrderedList { ref mut items,.. } | UnorderedList { ref mut items } =>
for item in items.iter_mut() {
item.fix_links(link_map);
},
Paragraph(ref mut content) | Heading { ref mut content,.. } =>
content.fix_links(link_map),
... | impl FixLinks for Block {
fn fix_links(&mut self, link_map: &LinkMap) {
match *self {
BlockQuote(ref mut content) => content.fix_links(link_map),
| random_line_split |
tokens.rs | use std::collections::HashMap;
pub use self::Block::*;
pub use self::Inline::*;
pub type Document = Vec<Block>;
pub type Text = Vec<Inline>;
pub type LinkMap = HashMap<String, LinkDescription>;
pub struct LinkDescription {
pub id: String,
pub link: String,
pub title: Option<String>
}
#[derive(PartialE... |
}
}
fn fix_links(&mut self, link_map: &LinkMap);
}
impl FixLinks for Block {
fn fix_links(&mut self, link_map: &LinkMap) {
match *self {
BlockQuote(ref mut content) => content.fix_links(link_map),
OrderedList { ref mut items,.. } | UnorderedList { ref mut items } ... | {} | conditional_block |
tokens.rs | use std::collections::HashMap;
pub use self::Block::*;
pub use self::Inline::*;
pub type Document = Vec<Block>;
pub type Text = Vec<Inline>;
pub type LinkMap = HashMap<String, LinkDescription>;
pub struct LinkDescription {
pub id: String,
pub link: String,
pub title: Option<String>
}
#[derive(PartialE... | (&mut self, link_map: &LinkMap) {
match *self {
Emphasis(ref mut content) | MoreEmphasis(ref mut content) =>
content.fix_links(link_map),
Link { ref mut link, ref mut title, id: Some(ref id),.. } => {
match link_map.get(id) {
Some(ld) ... | fix_links | identifier_name |
skip_while.rs | use core::iter::*;
#[test]
fn test_iterator_skip_while() {
let xs = [0, 1, 2, 3, 5, 13, 15, 16, 17, 19];
let ys = [15, 16, 17, 19];
let it = xs.iter().skip_while(|&x| *x < 15);
let mut i = 0;
for x in it {
assert_eq!(*x, ys[i]);
i += 1;
}
assert_eq!(i, ys.len());
}
#[test]
... | () {
let f = &|acc, x| i32::checked_add(2 * acc, x);
fn p(&x: &i32) -> bool {
(x % 10) <= 5
}
assert_eq!((1..20).skip_while(p).try_fold(7, f), (6..20).try_fold(7, f));
let mut iter = (1..20).skip_while(p);
assert_eq!(iter.nth(5), Some(11));
assert_eq!(iter.try_fold(7, f), (12..20).tr... | test_skip_while_try_fold | identifier_name |
skip_while.rs | use core::iter::*;
#[test]
fn test_iterator_skip_while() {
let xs = [0, 1, 2, 3, 5, 13, 15, 16, 17, 19];
let ys = [15, 16, 17, 19];
let it = xs.iter().skip_while(|&x| *x < 15);
let mut i = 0;
for x in it {
assert_eq!(*x, ys[i]);
i += 1;
}
assert_eq!(i, ys.len());
}
#[test]
... | #[test]
fn test_skip_while_try_fold() {
let f = &|acc, x| i32::checked_add(2 * acc, x);
fn p(&x: &i32) -> bool {
(x % 10) <= 5
}
assert_eq!((1..20).skip_while(p).try_fold(7, f), (6..20).try_fold(7, f));
let mut iter = (1..20).skip_while(p);
assert_eq!(iter.nth(5), Some(11));
assert_e... | });
assert_eq!(i, ys.len());
}
| random_line_split |
skip_while.rs | use core::iter::*;
#[test]
fn test_iterator_skip_while() {
let xs = [0, 1, 2, 3, 5, 13, 15, 16, 17, 19];
let ys = [15, 16, 17, 19];
let it = xs.iter().skip_while(|&x| *x < 15);
let mut i = 0;
for x in it {
assert_eq!(*x, ys[i]);
i += 1;
}
assert_eq!(i, ys.len());
}
#[test]
... |
assert_eq!((1..20).skip_while(p).try_fold(7, f), (6..20).try_fold(7, f));
let mut iter = (1..20).skip_while(p);
assert_eq!(iter.nth(5), Some(11));
assert_eq!(iter.try_fold(7, f), (12..20).try_fold(7, f));
let mut iter = (0..50).skip_while(|&x| (x % 20) < 15);
assert_eq!(iter.try_fold(0, i8::ch... | {
(x % 10) <= 5
} | identifier_body |
simpleapi.rs | // Simple API example, ported from http://lua-users.org/wiki/SimpleLuaApiExample
// This is a simple introductory example of how to interface to Lua from Rust.
// The Rust program loads a Lua script file, sets some Lua variables, runs the
// Lua script, and reads back the return value.
#![allow(uppercase_variables)]
... | * want the script to receive it, then ask Lua to run it.
*/
L.newtable(); // We will pass a table
/*
* To put values into the table, we first push the index, then the
* value, and then call rawset() with the index of the table in the
* stack. Let's see why it's -3: In Lua, the value -1... | {
let mut L = lua::State::new();
L.openlibs(); // Load Lua libraries
// Load the file containing the script we are going to run
let path = Path::new("simpleapi.lua");
match L.loadfile(Some(&path)) {
Ok(_) => (),
Err(_) => {
// If something went wrong, error message is at... | identifier_body |
simpleapi.rs | // Simple API example, ported from http://lua-users.org/wiki/SimpleLuaApiExample
// This is a simple introductory example of how to interface to Lua from Rust.
// The Rust program loads a Lua script file, sets some Lua variables, runs the
// Lua script, and reads back the return value.
#![allow(uppercase_variables)]
... |
// Get the returned value at the to of the stack (index -1)
let sum = L.tonumber(-1);
println!("Script returned: {}", sum);
L.pop(1); // Take the returned value out of the stack
// L's destructor will close the state for us
} | "Failed to run script: {}", L.describe(-1));
os::set_exit_status(1);
return;
}
} | random_line_split |
simpleapi.rs | // Simple API example, ported from http://lua-users.org/wiki/SimpleLuaApiExample
// This is a simple introductory example of how to interface to Lua from Rust.
// The Rust program loads a Lua script file, sets some Lua variables, runs the
// Lua script, and reads back the return value.
#![allow(uppercase_variables)]
... | () {
let mut L = lua::State::new();
L.openlibs(); // Load Lua libraries
// Load the file containing the script we are going to run
let path = Path::new("simpleapi.lua");
match L.loadfile(Some(&path)) {
Ok(_) => (),
Err(_) => {
// If something went wrong, error message is... | main | identifier_name |
extend_corpora.rs | // Copyright 2015-2018 Deyan Ginev. See the LICENSE
// file at the top-level directory of this distribution.
//
// Licensed under the MIT license <LICENSE-MIT or http://opensource.org/licenses/MIT>.
// This file may not be copied, modified, or distributed
// except according to those terms.
use cortex::backend::Backend... | () {
// Note that we realize the initial import via a real cortex worker, but use a simply utility
// script for extensions. this is the case since the goal here is to do a simple sysadmin
// "maintenance update", rather than a full-blown "semantic" union operation
let backend = Backend::default();
// If inp... | main | identifier_name |
extend_corpora.rs | // Copyright 2015-2018 Deyan Ginev. See the LICENSE
// file at the top-level directory of this distribution.
//
// Licensed under the MIT license <LICENSE-MIT or http://opensource.org/licenses/MIT>.
// This file may not be copied, modified, or distributed
// except according to those terms.
use cortex::backend::Backend... |
// Then re-register all services, so that they pick up on the tasks
let register_start = time::get_time();
match corpus.select_services(&backend.connection) {
Ok(services) => {
for service in services {
let service_id = service.id;
if service_id > 2 {
println!(... | let extend_duration = (extend_end - extend_start).num_milliseconds();
println!(
"-- Extending corpus {:?} took {:?}ms",
corpus.name, extend_duration
); | random_line_split |
extend_corpora.rs | // Copyright 2015-2018 Deyan Ginev. See the LICENSE
// file at the top-level directory of this distribution.
//
// Licensed under the MIT license <LICENSE-MIT or http://opensource.org/licenses/MIT>.
// This file may not be copied, modified, or distributed
// except according to those terms.
use cortex::backend::Backend... | };
for corpus in corpora {
// First, build an importer, which will perform the extension
let importer = Importer {
corpus: corpus.clone(),
backend: Backend::default(),
cwd: Importer::cwd(),
};
// Extend the already imported corpus. I prefer that method name to "update", as we won... | {
// Note that we realize the initial import via a real cortex worker, but use a simply utility
// script for extensions. this is the case since the goal here is to do a simple sysadmin
// "maintenance update", rather than a full-blown "semantic" union operation
let backend = Backend::default();
// If input ... | identifier_body |
mod.rs | //! cache/mod.rs - Provides the ModuleCache struct which the ante compiler
//! pervasively uses to cache and store results from various compiler phases.
//! The most important things the cache stores are additional information about
//! the parse tree. For example, for each variable definition, there is a corresponding... | /// The corresponding DefinitionInfoId is attatched to each
/// `ast::Variable` during name resolution.
#[derive(Debug)]
pub struct DefinitionInfo<'a> {
pub name: String,
pub location: Location<'a>,
/// Where this name was defined. It is expected that type checking
/// this Definition kind should resul... | /// Note that two variables defined in the same pattern, e.g: `(a, b) = c`
/// will have their own unique `DefinitionInfo`s, but each DefinitionInfo
/// will refer to the same `ast::Definition` in its definition field.
/// | random_line_split |
mod.rs | //! cache/mod.rs - Provides the ModuleCache struct which the ante compiler
//! pervasively uses to cache and store results from various compiler phases.
//! The most important things the cache stores are additional information about
//! the parse tree. For example, for each variable definition, there is a corresponding... | (&self) -> Location<'a> {
self.location
}
}
/// An ImplScopeId is attached to an ast::Variable to remember
/// the impls that were in scope when it was used since scopes are
/// thrown away after name resolution but the impls in scope are still
/// needed during type inference.
/// TODO: The concept of an ... | locate | identifier_name |
ide.rs | use machine::{outb, inb, inl};
use malloc::must_allocate;
use core::slice;
use collections::Vec;
use paging::PAGE_SIZE;
const SECTOR_BYTES: usize = 512;
const PORTS: [u16; 2] = [0x1f0, 0x170];
#[inline]
fn controller(drive: u8) -> u8 { (drive >> 1) & 1 }
#[inline]
fn channel(drive: u8) -> u8 { drive & 1 }
#[inline]... |
}
Some(sector_count)
}
pub fn read_sectors(drive: u8, start_sector: u32, buffer: &mut [u32]) {
let base = port(drive);
let channel = channel(drive);
let longs = buffer.len() as u32;
let num_sectors = longs >> 7;
let mut sector = start_sector;
let end_sector = start_sector + num_sector... | {
sector_count = result;
} | conditional_block |
ide.rs | use machine::{outb, inb, inl};
use malloc::must_allocate;
use core::slice;
use collections::Vec;
use paging::PAGE_SIZE;
const SECTOR_BYTES: usize = 512;
const PORTS: [u16; 2] = [0x1f0, 0x170];
#[inline]
fn controller(drive: u8) -> u8 { (drive >> 1) & 1 }
#[inline]
fn channel(drive: u8) -> u8 { drive & 1 }
#[inline]... | wait_for_data(drive);
for _ in 0..(SECTOR_BYTES / ::core::mem::size_of::<u32>()) {
buffer[buffer_idx] = inl(base);
buffer_idx += 1;
}
}
sector += sector_count as u32;
}
}
// You have to manually free the pointer when you stop cari... | {
let base = port(drive);
let channel = channel(drive);
let longs = buffer.len() as u32;
let num_sectors = longs >> 7;
let mut sector = start_sector;
let end_sector = start_sector + num_sectors;
let mut buffer_idx = 0;
while sector < end_sector {
// Read as many sectors as you c... | identifier_body |
ide.rs | use machine::{outb, inb, inl};
use malloc::must_allocate;
use core::slice;
use collections::Vec;
use paging::PAGE_SIZE;
const SECTOR_BYTES: usize = 512;
const PORTS: [u16; 2] = [0x1f0, 0x170];
#[inline]
fn controller(drive: u8) -> u8 { (drive >> 1) & 1 }
#[inline]
fn channel(drive: u8) -> u8 { drive & 1 }
#[inline]... | outb(base + 7, 0x20);
for _ in 0..sector_count {
wait_for_data(drive);
for _ in 0..(SECTOR_BYTES / ::core::mem::size_of::<u32>()) {
buffer[buffer_idx] = inl(base);
buffer_idx += 1;
}
}
sector += sector_count as u32;
... | outb(base + 2, sector_count);
outb(base + 3, sector as u8);
outb(base + 4, (sector >> 8) as u8);
outb(base + 5, (sector >> 16) as u8);
outb(base + 6, 0xE0 | (channel << 4) | (((sector >> 24) & 0xf) as u8)); | random_line_split |
ide.rs | use machine::{outb, inb, inl};
use malloc::must_allocate;
use core::slice;
use collections::Vec;
use paging::PAGE_SIZE;
const SECTOR_BYTES: usize = 512;
const PORTS: [u16; 2] = [0x1f0, 0x170];
#[inline]
fn controller(drive: u8) -> u8 { (drive >> 1) & 1 }
#[inline]
fn channel(drive: u8) -> u8 { drive & 1 }
#[inline]... | (drive: u8) -> Option<Vec<u32>> {
sector_count(drive).map(|count| {
let bytes = (count as usize) * SECTOR_BYTES;
let longs = bytes >> 2;
unsafe {
let pointer = must_allocate(bytes, PAGE_SIZE) as *mut u32; // Code should be page-aligned
read_sectors(drive, 0, slice::fr... | slurp_drive | identifier_name |
where-clauses-not-parameter.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 ... | () -> bool where Option<isize> : Eq {}
//~^ ERROR cannot bound type `core::option::Option<isize>`, where clause bounds may
#[derive(PartialEq)]
//~^ ERROR cannot bound type `isize`, where clause bounds
enum Foo<T> where isize : Eq { MkFoo }
//~^ ERROR cannot bound type `isize`, where clause bounds
fn test3<T: Eq>() -... | test2 | identifier_name |
where-clauses-not-parameter.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 ... | {
equal(&0is, &0is);
} | identifier_body | |
where-clauses-not-parameter.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 |
fn equal<T>(_: &T, _: &T) -> bool where isize : Eq {
true //~^ ERROR cannot bound type `isize`, where clause bounds may only be attached
}
// This should be fine involves a type parameter.
fn test<T: Eq>() -> bool where Option<T> : Eq {}
// This should be rejected as well.
fn test2() -> bool where Option<isize> ... | // <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. | random_line_split |
uievent.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 https://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods;
use crate::dom::bindings::codegen::Bindi... |
event.init_event(Atom::from(type_), can_bubble, cancelable);
self.view.set(view);
self.detail.set(detail);
}
// https://dom.spec.whatwg.org/#dom-event-istrusted
fn IsTrusted(&self) -> bool {
self.event.IsTrusted()
}
}
| {
return;
} | conditional_block |
uievent.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 https://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods;
use crate::dom::bindings::codegen::Bindi... | pub fn Constructor(
window: &Window,
type_: DOMString,
init: &UIEventBinding::UIEventInit,
) -> Fallible<DomRoot<UIEvent>> {
let bubbles = EventBubbles::from(init.parent.bubbles);
let cancelable = EventCancelable::from(init.parent.cancelable);
let event = UIEvent:... | detail,
);
ev
}
| random_line_split |
uievent.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 https://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods;
use crate::dom::bindings::codegen::Bindi... | () -> UIEvent {
UIEvent {
event: Event::new_inherited(),
view: Default::default(),
detail: Cell::new(0),
}
}
pub fn new_uninitialized(window: &Window) -> DomRoot<UIEvent> {
reflect_dom_object(
Box::new(UIEvent::new_inherited()),
... | new_inherited | identifier_name |
trait-object-reference-without-parens-suggestion.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 ... | () {
let _: &Copy +'static;
//~^ ERROR expected a path
//~| HELP try adding parentheses
//~| SUGGESTION let _: &(Copy +'static);
let _: &'static Copy +'static;
//~^ ERROR expected a path
//~| HELP try adding parentheses
//~| SUGGESTION let _: &'static (Copy +'static);
}
| main | identifier_name |
trait-object-reference-without-parens-suggestion.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 http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn main() {
... | random_line_split | |
trait-object-reference-without-parens-suggestion.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 ... | {
let _: &Copy + 'static;
//~^ ERROR expected a path
//~| HELP try adding parentheses
//~| SUGGESTION let _: &(Copy + 'static);
let _: &'static Copy + 'static;
//~^ ERROR expected a path
//~| HELP try adding parentheses
//~| SUGGESTION let _: &'static (Copy + 'static);
} | identifier_body | |
abortable.rs | use crate::task::AtomicWaker;
use futures_core::future::Future;
use futures_core::task::{Context, Poll};
use pin_utils::unsafe_pinned;
use core::fmt;
use core::pin::Pin;
use core::sync::atomic::{AtomicBool, Ordering};
use alloc::sync::Arc;
/// A future which can be remotely short-circuited using an `AbortHandle`.
#[de... | let (handle, reg) = AbortHandle::new_pair();
(
Abortable::new(future, reg),
handle,
)
}
/// Indicator that the `Abortable` future was aborted.
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub struct Aborted;
impl fmt::Display for Aborted {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> f... | /// This function is only available when the `std` or `alloc` feature of this
/// library is activated, and it is activated by default.
pub fn abortable<Fut>(future: Fut) -> (Abortable<Fut>, AbortHandle)
where Fut: Future
{ | random_line_split |
abortable.rs | use crate::task::AtomicWaker;
use futures_core::future::Future;
use futures_core::task::{Context, Poll};
use pin_utils::unsafe_pinned;
use core::fmt;
use core::pin::Pin;
use core::sync::atomic::{AtomicBool, Ordering};
use alloc::sync::Arc;
/// A future which can be remotely short-circuited using an `AbortHandle`.
#[de... | (&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "`Abortable` future has been aborted")
}
}
#[cfg(feature = "std")]
impl std::error::Error for Aborted {}
impl<Fut> Future for Abortable<Fut> where Fut: Future {
type Output = Result<Fut::Output, Aborted>;
fn poll(mut self: Pin<&mut Se... | fmt | identifier_name |
abortable.rs | use crate::task::AtomicWaker;
use futures_core::future::Future;
use futures_core::task::{Context, Poll};
use pin_utils::unsafe_pinned;
use core::fmt;
use core::pin::Pin;
use core::sync::atomic::{AtomicBool, Ordering};
use alloc::sync::Arc;
/// A future which can be remotely short-circuited using an `AbortHandle`.
#[de... |
// attempt to complete the future
if let Poll::Ready(x) = self.as_mut().future().poll(cx) {
return Poll::Ready(Ok(x))
}
// Register to receive a wakeup if the future is aborted in the... future
self.inner.waker.register(cx.waker());
// Check to see if the ... | {
return Poll::Ready(Err(Aborted))
} | conditional_block |
abortable.rs | use crate::task::AtomicWaker;
use futures_core::future::Future;
use futures_core::task::{Context, Poll};
use pin_utils::unsafe_pinned;
use core::fmt;
use core::pin::Pin;
use core::sync::atomic::{AtomicBool, Ordering};
use alloc::sync::Arc;
/// A future which can be remotely short-circuited using an `AbortHandle`.
#[de... |
}
/// A registration handle for a `Abortable` future.
/// Values of this type can be acquired from `AbortHandle::new` and are used
/// in calls to `Abortable::new`.
#[derive(Debug)]
pub struct AbortRegistration {
inner: Arc<AbortInner>,
}
/// A handle to a `Abortable` future.
#[derive(Debug, Clone)]
pub struct A... | {
Abortable {
future,
inner: reg.inner,
}
} | identifier_body |
preprocess.rs | // C preprocessor
use crate::token::*;
use std::cell::RefCell;
use std::collections::HashMap;
thread_local! {
static MACROS: RefCell<HashMap<String, Macro>> = RefCell::new(HashMap::new());
static ENV: RefCell<Env> = RefCell::new(Env::new());
}
fn set_env(env: Env) {
ENV.with(|c| {
*c.borrow_mut(... | }
})
}
fn env_output() -> Vec<Token> {
ENV.with(|c| {
return c.borrow().output.clone();
})
}
fn macros_get(key: &String) -> Option<Macro> {
MACROS.with(|m| {
match m.borrow().get(key) {
Some(v) => Some(v.clone()),
None => None,
}
})
}
fn mac... | *c.borrow_mut() = *prev.unwrap(); | random_line_split |
preprocess.rs | // C preprocessor
use crate::token::*;
use std::cell::RefCell;
use std::collections::HashMap;
thread_local! {
static MACROS: RefCell<HashMap<String, Macro>> = RefCell::new(HashMap::new());
static ENV: RefCell<Env> = RefCell::new(Env::new());
}
fn set_env(env: Env) {
ENV.with(|c| {
*c.borrow_mut(... | (key: &String) -> Option<Macro> {
MACROS.with(|m| {
match m.borrow().get(key) {
Some(v) => Some(v.clone()),
None => None,
}
})
}
fn macros_put(key: String, value: Macro) {
MACROS.with(|m| {
m.borrow_mut().insert(key, value);
})
}
#[derive(Clone, Debug)]
... | macros_get | identifier_name |
preprocess.rs | // C preprocessor
use crate::token::*;
use std::cell::RefCell;
use std::collections::HashMap;
thread_local! {
static MACROS: RefCell<HashMap<String, Macro>> = RefCell::new(HashMap::new());
static ENV: RefCell<Env> = RefCell::new(Env::new());
}
fn set_env(env: Env) {
ENV.with(|c| {
*c.borrow_mut(... | else {
bad_token(&t, "unknown directive".to_string());
}
}
let v = env_output();
env_pop();
return v;
}
| {
include();
} | conditional_block |
preprocess.rs | // C preprocessor
use crate::token::*;
use std::cell::RefCell;
use std::collections::HashMap;
thread_local! {
static MACROS: RefCell<HashMap<String, Macro>> = RefCell::new(HashMap::new());
static ENV: RefCell<Env> = RefCell::new(Env::new());
}
fn set_env(env: Env) {
ENV.with(|c| {
*c.borrow_mut(... |
}
fn new_env(prev: Option<Env>, input: Vec<Token>) -> Env {
let mut ctx = Env::new();
ctx.input = input;
if prev.is_none() {
ctx.prev = None;
} else {
ctx.prev = Some(Box::new(prev.unwrap()));
}
return ctx;
}
#[derive(Clone, Debug, PartialEq)]
enum MacroType {
OBJLIKE,
... | {
Env {
input: Vec::new(),
output: Vec::new(),
pos: 0,
prev: None,
}
} | identifier_body |
mod.rs | #![cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd"))]
use Api;
use BuilderAttribs;
use ContextError;
use CreationError;
use GlContext;
use PixelFormat;
use libc;
use api::osmesa::{self, OsMesaContext};
#[cfg(feature = "window")]
pub use self::api_dispatch::{Window, WindowProxy, MonitorID,... | (OsMesaContext);
impl HeadlessContext {
pub fn new(builder: BuilderAttribs) -> Result<HeadlessContext, CreationError> {
match OsMesaContext::new(builder) {
Ok(c) => return Ok(HeadlessContext(c)),
Err(osmesa::OsMesaCreationError::NotSupported) => (),
Err(osmesa::OsMesaCre... | HeadlessContext | identifier_name |
mod.rs | #![cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd"))]
use Api;
use BuilderAttribs;
use ContextError;
use CreationError;
use GlContext;
use PixelFormat;
use libc;
use api::osmesa::{self, OsMesaContext};
#[cfg(feature = "window")]
pub use self::api_dispatch::{Window, WindowProxy, MonitorID,... | fn get_api(&self) -> Api {
self.0.get_api()
}
#[inline]
fn get_pixel_format(&self) -> PixelFormat {
self.0.get_pixel_format()
}
} | #[inline] | random_line_split |
strx.rs | pub fn remove_to<'s>(s: &'s str, c: char) -> &'s str {
match s.rfind(c) {
Some(pos) => s.slice_from(pos + 1),
None => s
}
}
#[allow(dead_code)]
pub fn remove_from_last<'s>(s: &'s str, c: char) -> &'s str {
match s.rfind(c) {
Some(pos) => s.slice_to(pos),
None => s,
}
}
... | use super::remove_to;
use super::remove_from_last;
use super::remove_prefix;
use super::remove_suffix;
#[test]
fn test_remove_to() {
assert_eq!("aaa", remove_to("aaa", '.'));
assert_eq!("bbb", remove_to("aaa.bbb", '.'));
assert_eq!("ccc", remove_to("aaa.bbb.ccc", '.'));
... | random_line_split | |
strx.rs | pub fn remove_to<'s>(s: &'s str, c: char) -> &'s str {
match s.rfind(c) {
Some(pos) => s.slice_from(pos + 1),
None => s
}
}
#[allow(dead_code)]
pub fn remove_from_last<'s>(s: &'s str, c: char) -> &'s str {
match s.rfind(c) {
Some(pos) => s.slice_to(pos),
None => s,
}
}
... |
#[test]
fn test_remove_prefix() {
assert_eq!("aaa", remove_prefix("bbbaaa", "bbb"));
}
#[test]
#[should_fail]
fn test_remove_prefix_fail() {
remove_prefix("aaa", "bbb");
}
#[test]
fn test_remove_suffix() {
assert_eq!("bbb", remove_suffix("bbbaaa", "aaa"));... | {
assert_eq!("aaa", remove_from_last("aaa", '.'));
assert_eq!("aaa", remove_from_last("aaa.bbb", '.'));
assert_eq!("aaa.bbb", remove_from_last("aaa.bbb.ccc", '.'));
} | identifier_body |
strx.rs | pub fn remove_to<'s>(s: &'s str, c: char) -> &'s str {
match s.rfind(c) {
Some(pos) => s.slice_from(pos + 1),
None => s
}
}
#[allow(dead_code)]
pub fn remove_from_last<'s>(s: &'s str, c: char) -> &'s str {
match s.rfind(c) {
Some(pos) => s.slice_to(pos),
None => s,
}
}
... | <'s>(s: &'s str, prefix: &str) -> &'s str {
if!s.starts_with(prefix) {
panic!();
}
s.slice_from(prefix.len())
}
#[cfg(test)]
mod test {
use super::remove_to;
use super::remove_from_last;
use super::remove_prefix;
use super::remove_suffix;
#[test]
fn test_remove_to() {
... | remove_prefix | identifier_name |
strx.rs | pub fn remove_to<'s>(s: &'s str, c: char) -> &'s str {
match s.rfind(c) {
Some(pos) => s.slice_from(pos + 1),
None => s
}
}
#[allow(dead_code)]
pub fn remove_from_last<'s>(s: &'s str, c: char) -> &'s str {
match s.rfind(c) {
Some(pos) => s.slice_to(pos),
None => s,
}
}
... |
s.slice_to(s.len() - suffix.len())
}
pub fn remove_prefix<'s>(s: &'s str, prefix: &str) -> &'s str {
if!s.starts_with(prefix) {
panic!();
}
s.slice_from(prefix.len())
}
#[cfg(test)]
mod test {
use super::remove_to;
use super::remove_from_last;
use super::remove_prefix;
use su... | {
panic!();
} | conditional_block |
typeref.rs | /* automatically generated by rust-bindgen */
#![allow(non_snake_case)]
#[repr(C)]
pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
impl <T> __BindgenUnionField<T> {
#[inline]
pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) }
#[inline]
pub unsafe fn as_ref(&se... | #[derive(Debug, Copy)]
pub struct Position {
pub _address: u8,
}
#[test]
fn bindgen_test_layout_Position() {
assert_eq!(::std::mem::size_of::<Position>(), 1usize);
assert_eq!(::std::mem::align_of::<Position>(), 1usize);
}
impl Clone for Position {
fn clone(&self) -> Self { *self }
}
#[repr(C)]
#[derive(... | fn clone(&self) -> Self { *self }
}
#[repr(C)] | random_line_split |
typeref.rs | /* automatically generated by rust-bindgen */
#![allow(non_snake_case)]
#[repr(C)]
pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
impl <T> __BindgenUnionField<T> {
#[inline]
pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) }
#[inline]
pub unsafe fn as_ref(&se... | () {
assert_eq!(::std::mem::size_of::<Position>(), 1usize);
assert_eq!(::std::mem::align_of::<Position>(), 1usize);
}
impl Clone for Position {
fn clone(&self) -> Self { *self }
}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct Bar {
pub mFoo: *mut nsFoo,
}
#[test]
fn bindgen_test_layout_Bar() {
assert... | bindgen_test_layout_Position | identifier_name |
script_msg.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 canvas_traits::CanvasMsg;
use euclid::point::Point2D;
use euclid::size::Size2D;
use ipc_channel::ipc::IpcSende... | {
/// Indicates whether this pipeline is currently running animations.
ChangeRunningAnimationsState(PipelineId, AnimationState),
/// Layout task failure.
Failure(Failure),
/// Requests that the constellation inform the compositor of the a cursor change.
SetCursor(Cursor),
/// Notifies the c... | LayoutMsg | identifier_name |
script_msg.rs | use canvas_traits::CanvasMsg;
use euclid::point::Point2D;
use euclid::size::Size2D;
use ipc_channel::ipc::IpcSender;
use msg::constellation_msg::{AnimationState, DocumentState, IframeLoadInfo, NavigationDirection};
use msg::constellation_msg::{Failure, MozBrowserEvent, PipelineId};
use msg::constellation_msg::{LoadData... | /* 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 | |
coherence_inherent.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 ... | mod Lib {
pub trait TheTrait {
fn the_fn(&self);
}
pub struct TheStruct;
impl TheTrait for TheStruct {
fn the_fn(&self) {}
}
}
mod Import {
// Trait is in scope here:
use Lib::TheStruct;
use Lib::TheTrait;
fn call_the_fn(s: &TheStruct) {
s.the_fn();
}
... | // unless the trait is imported.
| random_line_split |
coherence_inherent.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 ... | (s: &TheStruct) {
s.the_fn(); //~ ERROR no method named `the_fn` found
}
}
fn main() {}
| call_the_fn | identifier_name |
coherence_inherent.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 ... |
}
mod NoImport {
// Trait is not in scope here:
use Lib::TheStruct;
fn call_the_fn(s: &TheStruct) {
s.the_fn(); //~ ERROR no method named `the_fn` found
}
}
fn main() {}
| {
s.the_fn();
} | identifier_body |
lib.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/. */
//! This module contains shared types and messages for use by devtools/script.
//! The traits are here instead of ... | pub name: String,
pub start_time: PreciseTime,
pub start_stack: Option<Vec<()>>,
pub end_time: PreciseTime,
pub end_stack: Option<Vec<()>>,
}
#[derive(Clone, Debug, Deserialize, Eq, Hash, MallocSizeOf, PartialEq, Serialize)]
pub enum TimelineMarkerType {
Reflow,
DOMEvent,
}
/// The propert... | start_stack: Option<Vec<()>>,
}
#[derive(Debug, Deserialize, Serialize)]
pub struct TimelineMarker { | random_line_split |
lib.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/. */
//! This module contains shared types and messages for use by devtools/script.
//! The traits are here instead of ... | {
HttpRequest(HttpRequest),
HttpResponse(HttpResponse),
}
impl TimelineMarker {
pub fn start(name: String) -> StartedTimelineMarker {
StartedTimelineMarker {
name: name,
start_time: PreciseTime::now(),
start_stack: None,
}
}
}
impl StartedTimelineMa... | NetworkEvent | identifier_name |
uart.rs | /*
* MIT License
*
* Copyright (c) 2018 Andre Richter <andre.o.richter@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation th... |
}
| {
unsafe { &*self.ptr() }
} | identifier_body |
uart.rs | /*
* MIT License
*
* Copyright (c) 2018 Andre Richter <andre.o.richter@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation th... |
asm::nop();
}
// write the character to the buffer
self.DR.set(c as u32);
}
fn wait_cycles(&self, cyc: u32) {
for _ in 0..cyc {
asm::nop();
}
}
}
impl ops::Deref for Uart {
type Target = RegisterBlock;
fn deref(&self) -> &Self::Ta... | {
break;
} | conditional_block |
uart.rs | /*
* MIT License
*
* Copyright (c) 2018 Andre Richter <andre.o.richter@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation th... | /// Returns a pointer to the register block
fn ptr(&self) -> *const RegisterBlock {
self.base_addr as *const _
}
///Set baud rate and characteristics (115200 8N1) and map to GPIO
pub fn init(&self, mbox: &mut mbox::Mbox, gpio: &gpio::GPIO) -> Result<(), &'static str> {
// turn off U... | }
| random_line_split |
uart.rs | /*
* MIT License
*
* Copyright (c) 2018 Andre Richter <andre.o.richter@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation th... | {
DR: ReadWrite<u32>,
__reserved_0: [u32; 5],
FR: ReadOnly<u32, FR::Register>,
__reserved_1: [u32; 2],
IBRD: WriteOnly<u32, IBRD::Register>,
FBRD: WriteOnly<u32, FBRD::Register>,
LCRH: WriteOnly<u32, LCRH::Register>,
CR: WriteOnly<u32, CR::Register>,
__reserved_2: [u32; 4],
ICR:... | RegisterBlock | identifier_name |
from_primitive_int.rs | use malachite_base::num::basic::traits::One;
use malachite_nz::natural::Natural;
use Rational;
macro_rules! impl_from_unsigned {
($t: ident) => {
impl From<$t> for Rational {
/// Converts a value to an `Integer`, where the value is of a primitive unsigned integer
/// type.
... | ///
/// # Examples
/// See the documentation of the `conversion::from_primitive_int` module.
#[inline]
fn from(i: $t) -> Rational {
Rational {
sign: i >= 0,
numerator: Natural::from(i.unsigned_abs()),
... | /// # Worst-case complexity
/// Constant time and additional memory. | random_line_split |
p069.rs | const N:usize = 1_000_000;
fn prime(p:&mut [usize]) {
for i in 2..N+1 {
if p[i]!= 0 {
continue ;
}
for j in i..N+1 {
if j*i > N {
break;
}
p[j*i] = i;
}
}
}
fn | (p:&[usize], v:usize) -> f32 {
let mut ps = Vec::new();
let mut vv = v;
while p[vv]!= 0 {
let pr = p[vv];
ps.push(pr);
while vv % pr == 0 {
vv/=pr;
}
}
if vv!= 1 {
ps.push(vv);
}
// print!("{} :",v);
// for i in &ps {
// print!(... | phi_n | identifier_name |
p069.rs | const N:usize = 1_000_000;
fn prime(p:&mut [usize]) {
for i in 2..N+1 {
if p[i]!= 0 {
continue ;
}
for j in i..N+1 {
if j*i > N {
break;
}
p[j*i] = i;
}
}
}
fn phi_n(p:&[usize], v:usize) -> f32 {
let mut ps = V... |
// print!("{} :",v);
// for i in &ps {
// print!("{} ",i);
// }
// println!("");
let mut cnt = v as i32;
for i in 1..(1<<ps.len()) {
let mut mulres = 1;
let mut bitcnt = 1;
for j in 0..ps.len() {
if i & (1<<j)!= 0 {
mulres *= ps[j];
... | {
ps.push(vv);
} | conditional_block |
p069.rs | const N:usize = 1_000_000;
fn prime(p:&mut [usize]) {
for i in 2..N+1 {
if p[i]!= 0 {
continue ;
}
for j in i..N+1 {
if j*i > N {
break;
}
p[j*i] = i;
}
}
}
fn phi_n(p:&[usize], v:usize) -> f32 {
let mut ps = V... | ans = (i,ret)
}
}
println!("{:?}",ans);
} | random_line_split | |
p069.rs | const N:usize = 1_000_000;
fn prime(p:&mut [usize]) {
for i in 2..N+1 {
if p[i]!= 0 {
continue ;
}
for j in i..N+1 {
if j*i > N {
break;
}
p[j*i] = i;
}
}
}
fn phi_n(p:&[usize], v:usize) -> f32 {
let mut ps = V... | {
let mut arr =[0 as usize;N+10];
prime(&mut arr);
let mut ans = (1,2.0);
for i in 2..N+1 {
let ret = phi_n(&arr, i);
if ret > ans.1 {
ans = (i,ret)
}
}
println!("{:?}",ans);
} | identifier_body | |
log-knows-the-names-of-variants-in-std.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... | check_log(exp, x);
} | x = None;
let exp = "None".to_string();
let act = format!("{:?}", x);
assert_eq!(act, exp); | random_line_split |
log-knows-the-names-of-variants-in-std.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... | <T>(exp: String, v: T) {
assert_eq!(exp, format!("{:?}", v));
}
pub fn main() {
let mut x = Some(a(22u));
let exp = "Some(a(22u))".to_string();
let act = format!("{:?}", x);
assert_eq!(act, exp);
check_log(exp, x);
x = None;
let exp = "None".to_string();
let act = format!("{:?}", x... | check_log | identifier_name |
liveness-use-after-send.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. | // option. This file may not be copied, modified, or distributed
// except according to those terms.
extern crate debug;
fn send<T:Send>(ch: _chan<T>, data: T) {
println!("{:?}", ch);
println!("{:?}", data);
fail!();
}
struct _chan<T>(int);
// Tests that "log(debug, message);" is flagged as using
// mes... | //
// 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 | random_line_split |
liveness-use-after-send.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 main() { fail!(); }
| {
send(ch, message);
println!("{:?}", message); //~ ERROR use of moved value: `message`
} | identifier_body |
liveness-use-after-send.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:Send>(ch: _chan<T>, data: T) {
println!("{:?}", ch);
println!("{:?}", data);
fail!();
}
struct _chan<T>(int);
// Tests that "log(debug, message);" is flagged as using
// message after the send deinitializes it
fn test00_start(ch: _chan<Box<int>>, message: Box<int>, _count: Box<int>) {
send(ch, mess... | send | identifier_name |
htmlframesetelement.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::HTMLFrameSetElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLFr... |
}
| {
self.htmlelement.reflector()
} | identifier_body |
htmlframesetelement.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::HTMLFrameSetElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLFr... | (localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLFrameSetElement> {
let element = HTMLFrameSetElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLFrameSetElementBinding::Wrap)
}
}
pub trait HTMLFrameSetElementMethods {
}
impl Reflectable fo... | new | identifier_name |
htmlframesetelement.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::HTMLFrameSetElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLFr... | #[deriving(Encodable)]
pub struct HTMLFrameSetElement {
pub htmlelement: HTMLElement
}
impl HTMLFrameSetElementDerived for EventTarget {
fn is_htmlframesetelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLFrameSetElementTypeId))
}
}
impl HTMLFrameSetElement {
pub ... | use dom::htmlelement::HTMLElement;
use dom::node::{Node, ElementNodeTypeId};
use servo_util::str::DOMString;
| random_line_split |
size_hint.rs | #![feature(core)]
extern crate core;
#[cfg(test)]
mod tests {
use core::option::Iter;
// #[derive(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)]
// #[stable(feature = "rust1", since = "1.0.0")]
// pub enum Option<T> {
// /// No value
// #[stable(feature = "rust1", since = "... | // type Item = &'a A;
//
// #[inline]
// fn next(&mut self) -> Option<&'a A> { self.inner.next() }
// #[inline]
// fn size_hint(&self) -> (usize, Option<usize>) { self.inner.size_hint() }
// }
type T = u32;
#[test]
fn size_hint_test1() {
let x: Option<T> = ... | // impl<'a, A> Iterator for Iter<'a, A> { | random_line_split |
size_hint.rs | #![feature(core)]
extern crate core;
#[cfg(test)]
mod tests {
use core::option::Iter;
// #[derive(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)]
// #[stable(feature = "rust1", since = "1.0.0")]
// pub enum Option<T> {
// /// No value
// #[stable(feature = "rust1", since = "... |
#[test]
fn size_hint_test2() {
let x: Option<T> = None::<T>;
let iter: Iter<T> = x.iter();
let (lower, upper): (usize, Option<usize>) = iter.size_hint();
assert_eq!(lower, 0);
assert_eq!(upper, Some::<usize>(0));
}
}
| {
let x: Option<T> = Some::<T>(7);
let iter: Iter<T> = x.iter();
let (lower, upper): (usize, Option<usize>) = iter.size_hint();
assert_eq!(lower, 1);
assert_eq!(upper, Some::<usize>(1));
} | identifier_body |
size_hint.rs | #![feature(core)]
extern crate core;
#[cfg(test)]
mod tests {
use core::option::Iter;
// #[derive(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)]
// #[stable(feature = "rust1", since = "1.0.0")]
// pub enum Option<T> {
// /// No value
// #[stable(feature = "rust1", since = "... | () {
let x: Option<T> = None::<T>;
let iter: Iter<T> = x.iter();
let (lower, upper): (usize, Option<usize>) = iter.size_hint();
assert_eq!(lower, 0);
assert_eq!(upper, Some::<usize>(0));
}
}
| size_hint_test2 | identifier_name |
common.rs | use core::fmt;
pub const SYS_DEBUG: usize = 0;
// Linux compatible
pub const SYS_BRK: usize = 45;
pub const SYS_CHDIR: usize = 12;
pub const SYS_CLOSE: usize = 6;
pub const SYS_CLONE: usize = 120;
pub const CLONE_VM: usize = 0x100;
pub const CLONE_FS: usize = 0x200;
pub const CLONE_FILES: usize = 0x400;
... | (&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
f.write_str(self.text())
}
}
pub const EPERM: isize = 1; /* Operation not permitted */
pub const ENOENT: isize = 2; /* No such file or directory */
pub const ESRCH: isize = 3; /* No such process */
pub const EINTR: isize = 4; /* Interrupted sy... | fmt | identifier_name |
common.rs | use core::fmt;
pub const SYS_DEBUG: usize = 0;
// Linux compatible
pub const SYS_BRK: usize = 45;
pub const SYS_CHDIR: usize = 12;
pub const SYS_CLOSE: usize = 6;
pub const SYS_CLONE: usize = 120;
pub const CLONE_VM: usize = 0x100;
pub const CLONE_FS: usize = 0x200;
pub const CLONE_FILES: usize = 0x400;
... | pub const ENOKEY: isize = 126; /* Required key not available */
pub const EKEYEXPIRED: isize = 127; /* Key has expired */
pub const EKEYREVOKED: isize = 128; /* Key has been revoked */
pub const EKEYREJECTED: isize = 129; /* Key was rejected by service */
pub const EOWNERDEAD: isize = 130; /* Owner died */
pub const EN... | pub const EMEDIUMTYPE: isize = 124; /* Wrong medium type */
pub const ECANCELED: isize = 125; /* Operation Canceled */ | random_line_split |
common.rs | use core::fmt;
pub const SYS_DEBUG: usize = 0;
// Linux compatible
pub const SYS_BRK: usize = 45;
pub const SYS_CHDIR: usize = 12;
pub const SYS_CLOSE: usize = 6;
pub const SYS_CLONE: usize = 120;
pub const CLONE_VM: usize = 0x100;
pub const CLONE_FS: usize = 0x200;
pub const CLONE_FILES: usize = 0x400;
... |
}
impl fmt::Display for SysError {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
f.write_str(self.text())
}
}
pub const EPERM: isize = 1; /* Operation not permitted */
pub const ENOENT: isize = 2; /* No such file or directory */
pub const ESRCH: isize = 3; /* No such process */... | {
f.write_str(self.text())
} | identifier_body |
vm.rs | use crate::{builder, ffi, util, Value};
use std;
use std::fmt;
use libc;
use std::sync::Mutex;
/// A Ruby virtual machine.
pub struct VM;
/// We only want to be able to have one `VM` at a time.
static mut VM_EXISTS: bool = false;
lazy_static! {
static ref ACTIVE_VM: Mutex<VM> = Mutex::new(VM::new().expect("fai... | else {
ffi::rb_eval_string_wrap
};
let result = unsafe { eval_fn(util::c_string(code).as_ptr(), &mut state) };
if state == 0 {
Ok(Value::from(result))
} else {
Err(ErrorKind::Exception(self.consume_exception()))
}
}
}
impl std::ops::Dro... | {
ffi::rb_eval_string_protect
} | conditional_block |
vm.rs | use crate::{builder, ffi, util, Value};
use std;
use std::fmt;
use libc;
use std::sync::Mutex;
/// A Ruby virtual machine.
pub struct VM;
/// We only want to be able to have one `VM` at a time.
static mut VM_EXISTS: bool = false;
lazy_static! {
static ref ACTIVE_VM: Mutex<VM> = Mutex::new(VM::new().expect("fai... | }
/// Gets the current receiver (can be `nil`).
pub fn current_receiver(&self) -> Value {
unsafe { Value::from(ffi::rb_current_receiver()) }
}
/// Raises an object and a message.
pub fn raise(&self, value: Value, message: &str) ->! {
unsafe { ffi::rb_raise(value.0, util::c_stri... | random_line_split | |
vm.rs | use crate::{builder, ffi, util, Value};
use std;
use std::fmt;
use libc;
use std::sync::Mutex;
/// A Ruby virtual machine.
pub struct | ;
/// We only want to be able to have one `VM` at a time.
static mut VM_EXISTS: bool = false;
lazy_static! {
static ref ACTIVE_VM: Mutex<VM> = Mutex::new(VM::new().expect("failed to create Ruby VM"));
}
// TODO:
// Implement hooked variables (rb_define_hooked_variable)
// Allows a callback to get/set variable ... | VM | identifier_name |
kinematic2.rs | extern crate nalgebra as na;
use na::{Point2, RealField, Vector2};
use ncollide2d::shape::{Ball, Cuboid, ShapeHandle};
use nphysics2d::force_generator::DefaultForceGeneratorSet;
use nphysics2d::joint::{DefaultJointConstraintSet, RevoluteJoint};
use nphysics2d::math::Velocity;
use nphysics2d::object::{
Body, BodyPa... |
});
/*
* Run the simulation.
*/
testbed.set_ground_handle(Some(ground_handle));
testbed.set_world(
mechanical_world,
geometrical_world,
bodies,
colliders,
joint_constraints,
force_generators,
);
testbed.look_at(Point2::new(0.0, 5.0), 60... | {
let platform_x = platform.position().translation.vector.x;
let mut vel = *platform.velocity();
vel.linear.y = (time * r!(5.0)).sin() * r!(0.8);
if platform_x >= rad * r!(10.0) {
vel.linear.x = r!(-1.0);
}
if platform_x <= -rad *... | conditional_block |
kinematic2.rs | extern crate nalgebra as na;
use na::{Point2, RealField, Vector2};
use ncollide2d::shape::{Ball, Cuboid, ShapeHandle};
use nphysics2d::force_generator::DefaultForceGeneratorSet;
use nphysics2d::joint::{DefaultJointConstraintSet, RevoluteJoint};
use nphysics2d::math::Velocity;
use nphysics2d::object::{
Body, BodyPa... | .build(BodyPartHandle(ground_handle, 0));
colliders.insert(co);
/*
* Create boxes
*/
let num = 10;
let rad = r!(0.2);
let cuboid = ShapeHandle::new(Cuboid::new(Vector2::repeat(rad)));
let collider_desc = ColliderDesc::new(cuboid.clone()).density(r!(1.0));
let shift = (rad... | {
/*
* World
*/
let mechanical_world = DefaultMechanicalWorld::new(Vector2::new(r!(0.0), r!(-9.81)));
let geometrical_world = DefaultGeometricalWorld::new();
let mut bodies = DefaultBodySet::new();
let mut colliders = DefaultColliderSet::new();
let joint_constraints = DefaultJointConst... | identifier_body |
kinematic2.rs | extern crate nalgebra as na;
use na::{Point2, RealField, Vector2};
use ncollide2d::shape::{Ball, Cuboid, ShapeHandle};
use nphysics2d::force_generator::DefaultForceGeneratorSet;
use nphysics2d::joint::{DefaultJointConstraintSet, RevoluteJoint};
use nphysics2d::math::Velocity;
use nphysics2d::object::{
Body, BodyPa... | () {
let testbed = Testbed::<f32>::from_builders(0, vec![("Kinematic body", init_world)]);
testbed.run()
}
| main | identifier_name |
kinematic2.rs | extern crate nalgebra as na;
use na::{Point2, RealField, Vector2};
use ncollide2d::shape::{Ball, Cuboid, ShapeHandle};
use nphysics2d::force_generator::DefaultForceGeneratorSet;
use nphysics2d::joint::{DefaultJointConstraintSet, RevoluteJoint};
use nphysics2d::math::Velocity;
use nphysics2d::object::{
Body, BodyPa... | * Setup a kinematic multibody.
*/
let joint = RevoluteJoint::new(r!(0.0));
let mut mb = MultibodyDesc::new(joint)
.body_shift(Vector2::x() * r!(2.0))
.parent_shift(Vector2::new(r!(5.0), r!(2.0)))
.build();
mb.set_status(BodyStatus::Kinematic);
mb.generalized_velocity_mut... |
/* | random_line_split |
lib.rs | // Copyright 2014 The Servo 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>, at ... | pub fn plugin_registrar(reg: &mut Registry) {
reg.register_macro("atom", atom::expand_atom);
reg.register_macro("ns", atom::expand_ns);
} |
// NB: This needs to be public or we get a linker error.
#[plugin_registrar] | random_line_split |
lib.rs | // Copyright 2014 The Servo 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>, at ... | (reg: &mut Registry) {
reg.register_macro("atom", atom::expand_atom);
reg.register_macro("ns", atom::expand_ns);
}
| plugin_registrar | identifier_name |
lib.rs | // Copyright 2014 The Servo 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>, at ... | {
reg.register_macro("atom", atom::expand_atom);
reg.register_macro("ns", atom::expand_ns);
} | identifier_body | |
blake2xb.rs | use core::cmp::{min};
use {Blake2b, Hash, ParameterBlock};
use slice_ext::{SliceExt};
use unbuffered;
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq)]
pub struct Blake2xb {
blake2b: Blake2b,
parameter_block: ParameterBlock,
len: u32,
}
pub struct Iter {
parameter_block: ParameterBlock,
block: [u64; 16],
block... | (&self) -> usize {
self.len as usize
}
pub fn update(&mut self, data: &[u8]) {
self.blake2b.update(data);
}
pub fn finish(self) -> Iter {
let mut block = [0; 16];
block[..8].copy_from_slice(&self.blake2b.finish().into_inner());
let parameter_block = self.parameter_block
.set_key_len(0)
.set_fanou... | len | identifier_name |
blake2xb.rs | use core::cmp::{min};
use {Blake2b, Hash, ParameterBlock};
use slice_ext::{SliceExt};
use unbuffered;
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq)]
pub struct Blake2xb {
blake2b: Blake2b,
parameter_block: ParameterBlock,
len: u32,
}
pub struct Iter {
parameter_block: ParameterBlock,
block: [u64; 16],
block... | else { 0 };
(i, Some(i))
}
}
| { 1 } | conditional_block |
blake2xb.rs | use core::cmp::{min};
use {Blake2b, Hash, ParameterBlock};
use slice_ext::{SliceExt};
use unbuffered;
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq)]
pub struct Blake2xb {
blake2b: Blake2b,
parameter_block: ParameterBlock,
len: u32,
}
pub struct Iter {
parameter_block: ParameterBlock,
block: [u64; 16],
block... | Self::with_parameter_block_keyed(len, key, parameter_block)
}
pub fn with_parameter_block_keyed(len: Option<u32>, key: &[u8], parameter_block: ParameterBlock) -> Self {
assert!(len.map(|len| len!= 0 && len!= u32::max_value()).unwrap_or(true), "len must be >= 1 and <= 2^32 - 2");
Blake2xb {
blake2b: Blake2b... | random_line_split | |
lib.rs | #![cfg(test)]
use ::rand::Rng;
use bincode_1::Options;
mod membership;
mod misc;
mod rand;
mod sway;
pub fn test_same_with_config<T, C, O>(t: &T, bincode_1_options: O, bincode_2_config: C)
where
T: bincode_2::Encode
+ bincode_2::Decode
+ serde::Serialize
+ serde::de::DeserializeOwned
... | &t,
bincode_1::options()
.with_little_endian()
.with_varint_encoding(),
bincode_2::config::legacy()
.with_little_endian()
.with_variable_int_encoding(),
);
test_same_with_config(
&t,
bincode_1::options()
.with_big_end... | {
test_same_with_config(
&t,
// This is the config used internally by bincode 1
bincode_1::options().with_fixint_encoding(),
// Should match `::legacy()`
bincode_2::config::legacy(),
);
// Check a bunch of different configs:
test_same_with_config(
&t,
... | identifier_body |
lib.rs | #![cfg(test)]
use ::rand::Rng;
use bincode_1::Options;
mod membership;
mod misc;
mod rand;
mod sway;
pub fn test_same_with_config<T, C, O>(t: &T, bincode_1_options: O, bincode_2_config: C)
where
T: bincode_2::Encode
+ bincode_2::Decode
+ serde::Serialize
+ serde::de::DeserializeOwned
... | .with_big_endian()
.with_variable_int_encoding(),
);
test_same_with_config(
&t,
bincode_1::options()
.with_little_endian()
.with_varint_encoding(),
bincode_2::config::legacy()
.with_little_endian()
.with_variable_int_encod... | bincode_2::config::legacy() | random_line_split |
lib.rs | #![cfg(test)]
use ::rand::Rng;
use bincode_1::Options;
mod membership;
mod misc;
mod rand;
mod sway;
pub fn test_same_with_config<T, C, O>(t: &T, bincode_1_options: O, bincode_2_config: C)
where
T: bincode_2::Encode
+ bincode_2::Decode
+ serde::Serialize
+ serde::de::DeserializeOwned
... | (rng: &mut impl Rng) -> String {
let len = rng.gen_range(0..100usize);
let mut result = String::with_capacity(len * 4);
for _ in 0..len {
result.push(rng.gen_range('\0'..char::MAX));
}
result
}
| gen_string | identifier_name |
iter-any.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!(!old_iter::any(&Some(1u), is_even));
assert!(old_iter::any(&Some(2u), is_even));
assert!(!old_iter::any(&None::<uint>, is_even));
} | pub fn main() {
assert!(![1u, 3u].any(is_even));
assert!([1u, 2u].any(is_even));
assert!(![].any(is_even));
| random_line_split |
iter-any.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!(![1u, 3u].any(is_even));
assert!([1u, 2u].any(is_even));
assert!(![].any(is_even));
assert!(!old_iter::any(&Some(1u), is_even));
assert!(old_iter::any(&Some(2u), is_even));
assert!(!old_iter::any(&None::<uint>, is_even));
} | identifier_body | |
iter-any.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 ... | (x: &uint) -> bool { (*x % 2) == 0 }
pub fn main() {
assert!(![1u, 3u].any(is_even));
assert!([1u, 2u].any(is_even));
assert!(![].any(is_even));
assert!(!old_iter::any(&Some(1u), is_even));
assert!(old_iter::any(&Some(2u), is_even));
assert!(!old_iter::any(&None::<uint>, is_even));
}
| is_even | identifier_name |
mod.rs | // Copyright 2016 TiKV Project Authors. Licensed under Apache-2.0.
//! Storage Transactions
pub mod commands;
pub mod sched_pool;
pub mod scheduler;
mod actions;
pub use actions::{
acquire_pessimistic_lock::acquire_pessimistic_lock,
cleanup::cleanup,
commit::commit,
gc::gc,
prewrite::{prewrite, ... |
}
impl From<ErrorInner> for Error {
#[inline]
fn from(e: ErrorInner) -> Self {
Error(Box::new(e))
}
}
impl<T: Into<ErrorInner>> From<T> for Error {
#[inline]
default fn from(err: T) -> Self {
let err = err.into();
err.into()
}
}
pub type Result<T> = std::result::Resul... | {
std::error::Error::source(&self.0)
} | identifier_body |
mod.rs | // Copyright 2016 TiKV Project Authors. Licensed under Apache-2.0.
//! Storage Transactions
pub mod commands;
pub mod sched_pool;
pub mod scheduler;
mod actions;
pub use actions::{
acquire_pessimistic_lock::acquire_pessimistic_lock,
cleanup::cleanup,
commit::commit,
gc::gc,
prewrite::{prewrite, ... | (&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Display::fmt(&self.0, f)
}
}
impl std::error::Error for Error {
fn source(&self) -> Option<&(dyn std::error::Error +'static)> {
std::error::Error::source(&self.0)
}
}
impl From<ErrorInner> for Error {
#[inline]
fn from(e: Er... | fmt | identifier_name |
mod.rs | // Copyright 2016 TiKV Project Authors. Licensed under Apache-2.0.
//! Storage Transactions
pub mod commands;
pub mod sched_pool;
pub mod scheduler;
mod actions;
pub use actions::{
acquire_pessimistic_lock::acquire_pessimistic_lock,
cleanup::cleanup,
commit::commit,
gc::gc,
prewrite::{prewrite, ... | pub fn maybe_clone(&self) -> Option<ProcessResult> {
match self {
ProcessResult::PessimisticLockRes { res: Ok(r) } => {
Some(ProcessResult::PessimisticLockRes { res: Ok(r.clone()) })
}
_ => None,
}
}
}
quick_error! {
#[derive(Debug)]
p... |
impl ProcessResult { | random_line_split |
mod.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
mod heartbeat;
mod lsp_notification_dispatch;
mod lsp_request_dispatch;
mod lsp_state;
mod lsp_state_resources; | completion::{on_completion, on_resolve_completion_item},
explore_schema_for_type::{on_explore_schema_for_type, ExploreSchemaForType},
goto_definition::{
on_get_source_location_of_type_definition, on_goto_definition,
GetSourceLocationOfTypeDefinition,
},
graphql_tools::on_graphql_exec... | mod task_queue;
use crate::{
code_action::on_code_action, | random_line_split |
mod.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
mod heartbeat;
mod lsp_notification_dispatch;
mod lsp_request_dispatch;
mod lsp_state;
mod lsp_state_resources;
mod task_queue;
... |
let server_capabilities = serde_json::to_value(&server_capabilities)?;
let params = connection.initialize(server_capabilities)?;
let params: InitializeParams = serde_json::from_value(params)?;
Ok(params)
}
#[derive(Debug)]
pub enum Task {
InboundMessage(lsp_server::Message),
LSPState(lsp_stat... | {
let server_capabilities = ServerCapabilities {
// Enable text document syncing so we can know when files are opened/changed/saved/closed
text_document_sync: Some(TextDocumentSyncCapability::Kind(TextDocumentSyncKind::Full)),
completion_provider: Some(CompletionOptions {
resolv... | identifier_body |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.