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 |
|---|---|---|---|---|
graph.rs | //! A container for audio devices in an acyclic graph.
//!
//! A graph can be used when many audio devices need to connect in complex
//! topologies. It can connect each output channel of a device to any input
//! channel, provided that connection does not create a cycle.
//!
//! A graph is initialized by adding each d... |
).collect();
// While there are nodes with no input, we choose one, add it as the
// next node in our topology, and remove all edges from that node. Any
// nodes that lose their final edge are added to the edgeless set.
loop {
match no_inputs.pop_front() {
... | { None } | conditional_block |
graph.rs | //! channel, provided that connection does not create a cycle.
//!
//! A graph is initialized by adding each device as a node in the graph, and
//! then specifying the edges between devices. The graph will automatically
//! process the devices in order of their dependencies.
//!
//! # Example
//!
//! The following exa... | //! A container for audio devices in an acyclic graph.
//!
//! A graph can be used when many audio devices need to connect in complex
//! topologies. It can connect each output channel of a device to any input | random_line_split | |
graph.rs | //! A container for audio devices in an acyclic graph.
//!
//! A graph can be used when many audio devices need to connect in complex
//! topologies. It can connect each output channel of a device to any input
//! channel, provided that connection does not create a cycle.
//!
//! A graph is initialized by adding each d... | () {
let mock1 = MockAudioDevice::new("mock1", 1, 1);
let mock2 = MockAudioDevice::new("mock2", 1, 1);
let mut graph = DeviceGraph::new();
let mock1 = graph.add_node(mock1);
let mock2 = graph.add_node(mock2);
graph.add_edge(mock1, 0, mock2, 0).unwrap();
graph.add... | test_direct_cycle | identifier_name |
bwt.rs | use sa::{insert, suffix_array};
use std::ops::Index;
/// Generate the [Burrows-Wheeler Transform](https://en.wikipedia.org/wiki/Burrows%E2%80%93Wheeler_transform)
/// of the given input.
///
/// ``` rust
/// let text = String::from("The quick brown fox jumps over the lazy dog");
/// let bw = nucleic_acid::bwt(text.as... | }
let mut i = lf_vec[0] as usize;
lf_vec[0] = 0;
let mut counter = bwt_data.len() as u32 - 1;
// Only difference is that we replace the LF indices with the lengths of prefix
// from a particular position (in other words, the number of times
// it would take us t... | {
let mut map = Vec::new();
let mut count = vec![0u32; bwt_data.len()];
let mut idx = 0;
// generate the frequency map and forward frequency vector from BWT
for i in &bwt_data {
let value = insert(&mut map, *i);
count[idx] = value;
idx += 1;
... | identifier_body |
bwt.rs | use sa::{insert, suffix_array};
use std::ops::Index;
/// Generate the [Burrows-Wheeler Transform](https://en.wikipedia.org/wiki/Burrows%E2%80%93Wheeler_transform)
/// of the given input.
///
/// ``` rust
/// let text = String::from("The quick brown fox jumps over the lazy dog");
/// let bw = nucleic_acid::bwt(text.as... | } | random_line_split | |
bwt.rs | use sa::{insert, suffix_array};
use std::ops::Index;
/// Generate the [Burrows-Wheeler Transform](https://en.wikipedia.org/wiki/Burrows%E2%80%93Wheeler_transform)
/// of the given input.
///
/// ``` rust
/// let text = String::from("The quick brown fox jumps over the lazy dog");
/// let bw = nucleic_acid::bwt(text.as... | (map: &mut Vec<u32>) {
let mut idx = 0;
for i in 0..map.len() {
let c = map[i];
map[i] = idx;
idx += c;
}
}
/// Invert the BWT and generate the original data.
///
/// ``` rust
/// let text = String::from("Hello, world!");
/// let bw = nucleic_acid::bwt(text.as_bytes());
/// let ibw... | generate_occurrence_index | identifier_name |
albums.rs | use std::collections::HashMap;
use postgres::GenericConnection as PostgresConnection;
use db::pg::RowsExtension;
use library::Result;
const MAX_TOP_ALBUMS: i64 = 10;
#[derive(RustcEncodable)]
struct Track {
name: String,
is_favorite: bool,
scrobbles: Vec<i32>,
}
#[derive(RustcEncodable)]
pub struct Alb... |
pub fn total_albums(conn: &PostgresConnection) -> Result<i64> {
Ok(try!(conn.query("SELECT COUNT(*) FROM albums", &[])).fetch_column())
} | random_line_split | |
albums.rs | use std::collections::HashMap;
use postgres::GenericConnection as PostgresConnection;
use db::pg::RowsExtension;
use library::Result;
const MAX_TOP_ALBUMS: i64 = 10;
#[derive(RustcEncodable)]
struct Track {
name: String,
is_favorite: bool,
scrobbles: Vec<i32>,
}
#[derive(RustcEncodable)]
pub struct Alb... |
let name: String = rows.get(0).get("name");
let mut tracks = HashMap::<i32, Track>::new();
let query = "SELECT id, name, is_favorite FROM tracks WHERE album_id = $1";
for row in &try!(conn.query(query, &[&album_id])) {
tracks.insert(row.get("id"),
Track {
... | {
return Ok(None);
} | conditional_block |
albums.rs | use std::collections::HashMap;
use postgres::GenericConnection as PostgresConnection;
use db::pg::RowsExtension;
use library::Result;
const MAX_TOP_ALBUMS: i64 = 10;
#[derive(RustcEncodable)]
struct Track {
name: String,
is_favorite: bool,
scrobbles: Vec<i32>,
}
#[derive(RustcEncodable)]
pub struct Alb... | (conn: &PostgresConnection) -> Result<TopAlbums> {
let query = r#"
SELECT
artists.name as artist,
albums.name as album,
albums.plays as plays
FROM albums
LEFT JOIN artists ON artists.id = albums.artist_id
ORDER BY albums.plays DESC
OFFSET 0... | load_top_albums | identifier_name |
log-knows-the-names-of-variants.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!(~"d", fmt!("%?", d));
} | random_line_split | |
log-knows-the-names-of-variants.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!(~"a(22)", fmt!("%?", a(22u)));
assert_eq!(~"b(~\"hi\")", fmt!("%?", b(~"hi")));
assert_eq!(~"c", fmt!("%?", c));
assert_eq!(~"d", fmt!("%?", d));
} | identifier_body | |
log-knows-the-names-of-variants.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 ... | {
a(uint),
b(~str),
c,
}
enum bar {
d, e, f
}
pub fn main() {
assert_eq!(~"a(22)", fmt!("%?", a(22u)));
assert_eq!(~"b(~\"hi\")", fmt!("%?", b(~"hi")));
assert_eq!(~"c", fmt!("%?", c));
assert_eq!(~"d", fmt!("%?", d));
}
| foo | identifier_name |
borrowck-field-sensitivity.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 ... | drop(x.b);
drop(x.b); //~ ERROR use of moved value: `x.b`
}
fn move_after_fu_move() {
let x = A { a: 1, b: box 2 };
let _y = A { a: 3,.. x };
drop(x.b); //~ ERROR use of moved value: `x.b`
}
fn fu_move_after_move() {
let x = A { a: 1, b: box 2 };
drop(x.b);
let _z = A { a: 3,.. x }; ... | fn move_after_move() {
let x = A { a: 1, b: box 2 }; | random_line_split |
borrowck-field-sensitivity.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 = A { a: 1, b: box 2 };
drop(x.b);
let _z = A { a: 3,.. x }; //~ ERROR use of moved value: `x.b`
}
fn fu_move_after_fu_move() {
let x = A { a: 1, b: box 2 };
let _y = A { a: 3,.. x };
let _z = A { a: 4,.. x }; //~ ERROR use of moved value: `x.b`
}
// The following functions aren't... | fu_move_after_move | identifier_name |
borrowck-field-sensitivity.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 move_after_borrow() {
let x = A { a: 1, b: box 2 };
let p = &x.b;
drop(x.b); //~ ERROR cannot move out of `x.b` because it is borrowed
drop(**p);
}
fn fu_move_after_borrow() {
let x = A { a: 1, b: box 2 };
let p = &x.b;
let _y = A { a: 3,.. x }; //~ ERROR cannot move out of `x.b` becau... | {
let x = A { a: 1, b: box 2 };
let _y = A { a: 3, .. x };
let p = &x.b; //~ ERROR use of moved value: `x.b`
drop(**p);
} | identifier_body |
linux_base.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 ... | }
}
| {
TargetOptions {
linker: "cc".to_string(),
dynamic_linking: true,
executables: true,
morestack: true,
linker_is_gnu: true,
has_rpath: true,
pre_link_args: vec![
// We want to be able to strip as much executable code as possible
// from... | identifier_body |
linux_base.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 ... | ],
position_independent_executables: true,
.. Default::default()
}
} | random_line_split | |
linux_base.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 ... | () -> TargetOptions {
TargetOptions {
linker: "cc".to_string(),
dynamic_linking: true,
executables: true,
morestack: true,
linker_is_gnu: true,
has_rpath: true,
pre_link_args: vec![
// We want to be able to strip as much executable code as possible... | opts | identifier_name |
backend.rs | use std::env;
use dotenv::dotenv;
use diesel;
use diesel::prelude::*;
use diesel::pg::PgConnection;
use super::models::*;
use ::services::schema;
pub struct Backend {
connection: PgConnection
}
impl Backend {
pub fn new() -> Self {
dotenv().ok();
let database_url = env::var("DATABASE_URL")
... |
}
| {
use self::schema::voteables::dsl::*;
let entity = &entity.to_lowercase();
let mut res = voteables.filter(value.eq(entity))
.load(&self.connection).unwrap();
match res.len() {
0 => None,
_ => Some(res.pop().unwrap()),
}
... | identifier_body |
backend.rs | use std::env;
use dotenv::dotenv;
use diesel;
use diesel::prelude::*;
use diesel::pg::PgConnection;
use super::models::*;
use ::services::schema;
pub struct Backend {
connection: PgConnection
}
impl Backend {
pub fn new() -> Self {
dotenv().ok();
let database_url = env::var("DATABASE_URL")
... | (&self, user: &str, entity: &str, up: i32, down: i32) {
use self::schema::{users, voteables, votes};
let entity = &entity.to_lowercase();
use self::schema::users::dsl as us;
let mut res: Vec<User> = us::users.filter(us::user_id.eq(user))
.load(&... | vote | identifier_name |
backend.rs | use std::env;
use dotenv::dotenv;
use diesel;
use diesel::prelude::*;
use diesel::pg::PgConnection;
use super::models::*;
use ::services::schema;
pub struct Backend {
connection: PgConnection
}
impl Backend {
pub fn new() -> Self {
dotenv().ok();
let database_url = env::var("DATABASE_URL")
... | voteable.save_changes::<Voteable>(&self.connection);
use ::services::schema::votes::dsl as vts;
let mut res: Vec<Vote> = vts::votes.filter(vts::user_id.eq(user.id))
.filter(vts::voteable_id.eq(voteable.id))
.loa... | voteable.total_down += down; | random_line_split |
selector_parser.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/. */
//! Gecko-specific bits for selector-parsing.
use cssparser::{Parser, ToCss};
use element_state::ElementState;
us... |
true
}
}
impl NonTSPseudoClass {
/// A pseudo-class is internal if it can only be used inside
/// user agent style sheets.
pub fn is_internal(&self) -> bool {
macro_rules! check_flag {
(_) => (false);
($flags:expr) => ($flags.contains(PSEUDO_CLASS_INTERNAL));
... | {
for selector in selectors.iter() {
if !selector.visit(visitor) {
return false;
}
}
} | conditional_block |
selector_parser.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/. */
//! Gecko-specific bits for selector-parsing.
use cssparser::{Parser, ToCss};
use element_state::ElementState;
us... | (&self) -> bool {
matches!(*self, NonTSPseudoClass::Hover |
NonTSPseudoClass::Active |
NonTSPseudoClass::Focus)
}
/// Get the state flag associated with a pseudo-class, if any.
pub fn state_flag(&self) -> ElementState {
macro_rules! flag {
... | is_safe_user_action_state | identifier_name |
selector_parser.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/. */
//! Gecko-specific bits for selector-parsing.
use cssparser::{Parser, ToCss};
use element_state::ElementState;
us... |
/// Get the state flag associated with a pseudo-class, if any.
pub fn state_flag(&self) -> ElementState {
macro_rules! flag {
(_) => (ElementState::empty());
($state:ident) => (::element_state::$state);
}
macro_rules! pseudo_class_state {
(bare: [$((... | {
matches!(*self, NonTSPseudoClass::Hover |
NonTSPseudoClass::Active |
NonTSPseudoClass::Focus)
} | identifier_body |
selector_parser.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/. */
//! Gecko-specific bits for selector-parsing.
use cssparser::{Parser, ToCss};
use element_state::ElementState;
us... | match_ignore_ascii_case! { &name,
$($s_css => {
let name = parser.expect_ident_or_string()?;
// convert to null terminated utf16 string
// since that's what Gecko deals with
let utf16: Vec... | (bare: [$(($css:expr, $name:ident, $gecko_type:tt, $state:tt, $flags:tt),)*],
string: [$(($s_css:expr, $s_name:ident, $s_gecko_type:tt, $s_state:tt, $s_flags:tt),)*]) => { | random_line_split |
overloaded-index-in-field.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 ... | else {
&self.y
}
}
}
trait Int {
fn get(self) -> isize;
fn get_from_ref(&self) -> isize;
fn inc(&mut self);
}
impl Int for isize {
fn get(self) -> isize { self }
fn get_from_ref(&self) -> isize { *self }
fn inc(&mut self) { *self += 1; }
}
fn main() {
let f = Bar ... | {
&self.x
} | conditional_block |
overloaded-index-in-field.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 using ov... | random_line_split | |
overloaded-index-in-field.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: isize,
y: isize,
}
struct Bar {
foo: Foo
}
impl Index<isize> for Foo {
type Output = isize;
fn index(&self, z: isize) -> &isize {
if z == 0 {
&self.x
} else {
&self.y
}
}
}
trait Int {
fn get(self) -> isize;
fn get_from_ref(&self)... | Foo | identifier_name |
overloaded-index-in-field.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 ... |
}
trait Int {
fn get(self) -> isize;
fn get_from_ref(&self) -> isize;
fn inc(&mut self);
}
impl Int for isize {
fn get(self) -> isize { self }
fn get_from_ref(&self) -> isize { *self }
fn inc(&mut self) { *self += 1; }
}
fn main() {
let f = Bar { foo: Foo {
x: 1,
y: 2,
... | {
if z == 0 {
&self.x
} else {
&self.y
}
} | identifier_body |
associated-types-normalize-in-bounds-ufcs.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 that we nor... | // | random_line_split |
associated-types-normalize-in-bounds-ufcs.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 ... | () { }
| main | identifier_name |
serviceworkercontainer.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::ServiceWorkerContainerBinding::{ServiceWorkerContainerMethods, Wrap};
use do... | use dom::client::Client;
use dom::eventtarget::EventTarget;
use dom::globalscope::GlobalScope;
use dom::promise::Promise;
use dom::serviceworker::ServiceWorker;
use dom_struct::dom_struct;
use script_thread::ScriptThread;
use serviceworkerjob::{Job, JobType};
#[allow(unused_imports)] use std::ascii::AsciiExt;
use std::... | random_line_split | |
serviceworkercontainer.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::ServiceWorkerContainerBinding::{ServiceWorkerContainerMethods, Wrap};
use do... | (client: &Client) -> ServiceWorkerContainer {
ServiceWorkerContainer {
eventtarget: EventTarget::new_inherited(),
controller: Default::default(),
client: Dom::from_ref(client),
}
}
#[allow(unrooted_must_root)]
pub fn new(global: &GlobalScope) -> DomRoot<S... | new_inherited | identifier_name |
serviceworkercontainer.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::ServiceWorkerContainerBinding::{ServiceWorkerContainerMethods, Wrap};
use do... |
#[allow(unrooted_must_root)]
// https://w3c.github.io/ServiceWorker/#service-worker-container-register-method and - A
// https://w3c.github.io/ServiceWorker/#start-register-algorithm - B
fn Register(&self,
script_url: USVString,
options: &RegistrationOptions) -> Rc<Prom... | {
self.client.get_controller()
} | identifier_body |
testworkletglobalscope.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 crate::dom::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::TestWorkletGlobalScopeBin... |
}
/// Tasks which can be performed by test worklets.
pub enum TestWorkletTask {
Lookup(String, Sender<Option<String>>),
}
| {
debug!("Registering test worklet key/value {}/{}.", key, value);
self.lookup_table
.borrow_mut()
.insert(String::from(key), String::from(value));
} | identifier_body |
testworkletglobalscope.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 crate::dom::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::TestWorkletGlobalScopeBin... | {
Lookup(String, Sender<Option<String>>),
}
| TestWorkletTask | identifier_name |
testworkletglobalscope.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 crate::dom::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::TestWorkletGlobalScopeBin... | });
unsafe { TestWorkletGlobalScopeBinding::Wrap(runtime.cx(), global) }
}
pub fn perform_a_worklet_task(&self, task: TestWorkletTask) {
match task {
TestWorkletTask::Lookup(key, sender) => {
debug!("Looking up key {}.", key);
let result = sel... | random_line_split | |
dom_blob.rs | // This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use DOMObject;
use glib::object::Cast;
use glib::object::IsA;
use glib::signal::SignalHandlerId;
use glib::signal::connect_raw;
use glib::translate::*;
use glib_sys;
use std::boxed::... | impl fmt::Display for DOMBlob {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "DOMBlob")
}
} | random_line_split | |
dom_blob.rs | // This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use DOMObject;
use glib::object::Cast;
use glib::object::IsA;
use glib::signal::SignalHandlerId;
use glib::signal::connect_raw;
use glib::translate::*;
use glib_sys;
use std::boxed::... |
}
| {
write!(f, "DOMBlob")
} | identifier_body |
dom_blob.rs | // This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use DOMObject;
use glib::object::Cast;
use glib::object::IsA;
use glib::signal::SignalHandlerId;
use glib::signal::connect_raw;
use glib::translate::*;
use glib_sys;
use std::boxed::... | <P, F: Fn(&P) +'static>(this: *mut webkit2_webextension_sys::WebKitDOMBlob, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer)
where P: IsA<DOMBlob>
{
let f: &F = &*(f as *const F);
f(&DOMBlob::from_glib_borrow(this).unsafe_cast())
}
unsafe {
... | notify_size_trampoline | identifier_name |
vec.rs | #[no_std];
#[no_core];
use zero;
pub trait OwnedVector<T> {
unsafe fn push_fast(&mut self, t: T);
unsafe fn len(&self) -> uint;
unsafe fn set_len(&mut self, newlen: uint);
unsafe fn as_mut_buf<U>(&self, f: &fn(*mut T, uint) -> U) -> U;
unsafe fn data(&self) -> *u8;
}
pub struct Vec<T> {
fill:... | (&mut self, t: T) {
let repr: **mut Vec<u8> = zero::transmute(self);
let fill = (**repr).fill;
(**repr).fill += zero::size_of::<T>();
let p = &(**repr).data as *u8 as uint;
let mut i = 0;
while i < zero::size_of::<T>() {
*((p+fill+i) as *mut u8) = *((&t as *T... | push_fast | identifier_name |
vec.rs | #[no_std];
#[no_core];
use zero;
pub trait OwnedVector<T> {
unsafe fn push_fast(&mut self, t: T);
unsafe fn len(&self) -> uint;
unsafe fn set_len(&mut self, newlen: uint);
unsafe fn as_mut_buf<U>(&self, f: &fn(*mut T, uint) -> U) -> U;
unsafe fn data(&self) -> *u8;
}
pub struct Vec<T> {
fill:... |
unsafe fn len(&self) -> uint {
let repr: **Vec<u8> = zero::transmute(self);
((**repr).fill / zero::size_of::<T>()) as uint
}
unsafe fn set_len(&mut self, newlen: uint) {
let repr: **mut Vec<u8> = zero::transmute(self);
(**repr).fill = zero::size_of::<T>() * newlen;
}
... | {
let repr: **mut Vec<u8> = zero::transmute(self);
let fill = (**repr).fill;
(**repr).fill += zero::size_of::<T>();
let p = &(**repr).data as *u8 as uint;
let mut i = 0;
while i < zero::size_of::<T>() {
*((p+fill+i) as *mut u8) = *((&t as *T as uint + i) as *... | identifier_body |
vec.rs | #[no_std];
#[no_core];
use zero;
pub trait OwnedVector<T> {
unsafe fn push_fast(&mut self, t: T);
unsafe fn len(&self) -> uint;
unsafe fn set_len(&mut self, newlen: uint);
unsafe fn as_mut_buf<U>(&self, f: &fn(*mut T, uint) -> U) -> U;
unsafe fn data(&self) -> *u8;
}
pub struct Vec<T> {
fill:... | }
unsafe fn set_len(&mut self, newlen: uint) {
let repr: **mut Vec<u8> = zero::transmute(self);
(**repr).fill = zero::size_of::<T>() * newlen;
}
unsafe fn as_mut_buf<U>(&self, f: &fn(*mut T, uint) -> U) -> U {
let repr: **mut Vec<T> = zero::transmute(self);
f(&mut (**re... | random_line_split | |
issue-17651.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 ... | {
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
(|| Box::new(*(&[0][..])))();
//~^ ERROR the trait `core::marker::Sized` is not implemented for the type `[_]`
} | identifier_body | |
issue-17651.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 ... | () {
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
(|| Box::new(*(&[0][..])))();
//~^ ERROR the trait `core::marker::Sized` is not implemented for the type `[_]`
}
| main | identifier_name |
datastructures.rs | use std::iter;
use std::ops::{Index, IndexMut};
pub type Idx = [u32; 2];
#[derive(Debug)]
pub struct Matrix<T> {
shape: Idx,
data: Vec<Vec<T>>
}
impl<T: Copy> Matrix<T> {
pub fn fill(shape: Idx, value: T) -> Matrix<T> {
let data = (0..shape[0]).map(|_| {
iter::repeat(value).take(shape... | }
}
impl<T> IndexMut<Idx> for Matrix<T> {
fn index_mut(&mut self, index: Idx) -> &mut T {
let (x, y) = (index[0], index[1]);
assert!(x < self.width() && y < self.height());
&mut self.data[x as usize][y as usize]
}
} | let (x, y) = (index[0], index[1]);
assert!(x < self.width() && y < self.height());
&self.data[x as usize][y as usize] | random_line_split |
datastructures.rs | use std::iter;
use std::ops::{Index, IndexMut};
pub type Idx = [u32; 2];
#[derive(Debug)]
pub struct | <T> {
shape: Idx,
data: Vec<Vec<T>>
}
impl<T: Copy> Matrix<T> {
pub fn fill(shape: Idx, value: T) -> Matrix<T> {
let data = (0..shape[0]).map(|_| {
iter::repeat(value).take(shape[1] as usize)
.collect::<Vec<_>>()
}).collect::<Vec<_>>();
Matrix {
... | Matrix | identifier_name |
datastructures.rs | use std::iter;
use std::ops::{Index, IndexMut};
pub type Idx = [u32; 2];
#[derive(Debug)]
pub struct Matrix<T> {
shape: Idx,
data: Vec<Vec<T>>
}
impl<T: Copy> Matrix<T> {
pub fn fill(shape: Idx, value: T) -> Matrix<T> |
pub fn iter<'a>(&'a self) -> Box<Iterator<Item=(Idx, T)> + 'a> {
Box::new((0..self.height()).flat_map(move |y| {
(0..self.width()).map(move |x| ([x, y], self[[x, y]]))
}))
}
}
impl<T> Matrix<T> {
pub fn width(&self) -> u32 {
self.shape[0]
}
pub fn height(&self... | {
let data = (0..shape[0]).map(|_| {
iter::repeat(value).take(shape[1] as usize)
.collect::<Vec<_>>()
}).collect::<Vec<_>>();
Matrix {
shape: shape,
data: data
}
} | identifier_body |
partial_cmp_natural.rs | use malachite_base::num::arithmetic::traits::Sign;
use malachite_base::num::basic::traits::One;
use malachite_base::num::logic::traits::SignificantBits;
use malachite_nz::natural::Natural;
use std::cmp::Ordering;
use Rational;
impl PartialOrd<Natural> for Rational {
/// Compares a `Rational` to a `Natural`.
//... | (&self, other: &Rational) -> Option<Ordering> {
other.partial_cmp(self).map(Ordering::reverse)
}
}
| partial_cmp | identifier_name |
partial_cmp_natural.rs | use malachite_base::num::arithmetic::traits::Sign;
use malachite_base::num::basic::traits::One;
use malachite_base::num::logic::traits::SignificantBits;
use malachite_nz::natural::Natural;
use std::cmp::Ordering;
use Rational;
impl PartialOrd<Natural> for Rational {
/// Compares a `Rational` to a `Natural`.
//... | let sign_cmp = self_sign.cmp(&other_sign);
if sign_cmp!= Ordering::Equal || self_sign == Ordering::Equal {
return Some(sign_cmp);
}
// Then check if one is < 1 and the other is > 1
let self_cmp_one = self.numerator.cmp(&self.denominator);
let other_cmp_one = o... | let other_sign = other.sign(); | random_line_split |
partial_cmp_natural.rs | use malachite_base::num::arithmetic::traits::Sign;
use malachite_base::num::basic::traits::One;
use malachite_base::num::logic::traits::SignificantBits;
use malachite_nz::natural::Natural;
use std::cmp::Ordering;
use Rational;
impl PartialOrd<Natural> for Rational {
/// Compares a `Rational` to a `Natural`.
//... |
let first_prod_bits = self.numerator.significant_bits();
let second_prod_bits = self.denominator.significant_bits() + other.significant_bits();
if first_prod_bits < second_prod_bits - 1 {
return Some(Ordering::Less);
} else if first_prod_bits > second_prod_bits {
... | {
let nd_cmp = n_cmp.cmp(&d_cmp);
if nd_cmp != Ordering::Equal {
return Some(nd_cmp);
}
} | conditional_block |
partial_cmp_natural.rs | use malachite_base::num::arithmetic::traits::Sign;
use malachite_base::num::basic::traits::One;
use malachite_base::num::logic::traits::SignificantBits;
use malachite_nz::natural::Natural;
use std::cmp::Ordering;
use Rational;
impl PartialOrd<Natural> for Rational {
/// Compares a `Rational` to a `Natural`.
//... | } else {
let nd_cmp = n_cmp.cmp(&d_cmp);
if nd_cmp!= Ordering::Equal {
return Some(nd_cmp);
}
}
let first_prod_bits = self.numerator.significant_bits();
let second_prod_bits = self.denominator.significant_bits() + other.significant_bits... | {
// First check signs
let self_sign = self.sign();
let other_sign = other.sign();
let sign_cmp = self_sign.cmp(&other_sign);
if sign_cmp != Ordering::Equal || self_sign == Ordering::Equal {
return Some(sign_cmp);
}
// Then check if one is < 1 and the ... | identifier_body |
svh-a-change-trait-bound.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 ... | //! The `svh-a-*.rs` files are all deviations from the base file
//! svh-a-base.rs with some difference (usually in `fn foo`) that
//! should not affect the strict version hash (SVH) computation
//! (#14132).
#![crate_name = "a"]
macro_rules! three {
() => { 3 }
}
pub trait U {}
pub trait V {}
impl U for () {}
i... | random_line_split | |
svh-a-change-trait-bound.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 ... | <T:V>(_: int) -> int {
3
}
pub fn an_unused_name() -> int {
4
}
| foo | identifier_name |
svh-a-change-trait-bound.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 ... | {
4
} | identifier_body | |
main.rs | #[macro_use]
extern crate rocket;
#[macro_use]
extern crate rocket_contrib;
mod airport_data;
mod api;
mod path;
use airport_data::our_airports::OurAirports; | use anyhow::{Context, Result};
use rocket::config::{Config, Environment};
use rocket_contrib::serve::StaticFiles;
#[rocket::main]
async fn main() -> Result<()> {
let config = {
let env = Environment::active().context("failed to get Rocket config")?;
Config::build(env)
.workers(1)
... | use airport_data::AirportData; | random_line_split |
main.rs | #[macro_use]
extern crate rocket;
#[macro_use]
extern crate rocket_contrib;
mod airport_data;
mod api;
mod path;
use airport_data::our_airports::OurAirports;
use airport_data::AirportData;
use anyhow::{Context, Result};
use rocket::config::{Config, Environment};
use rocket_contrib::serve::StaticFiles;
#[rocket::mai... | () -> Result<()> {
let config = {
let env = Environment::active().context("failed to get Rocket config")?;
Config::build(env)
.workers(1)
.finalize()
.context("failed to build Rocket config")?
};
let mut airports_source = OurAirports::init().context("failed... | main | identifier_name |
main.rs | #[macro_use]
extern crate rocket;
#[macro_use]
extern crate rocket_contrib;
mod airport_data;
mod api;
mod path;
use airport_data::our_airports::OurAirports;
use airport_data::AirportData;
use anyhow::{Context, Result};
use rocket::config::{Config, Environment};
use rocket_contrib::serve::StaticFiles;
#[rocket::mai... | .load()
.context("failed to load OurAirports data")?;
println!("finished loading OurAirports data");
rocket::custom(config)
.manage(airports)
.mount("/", StaticFiles::from("frontend/public/"))
.mount("/api", routes![api::search_routes::search_routes])
.launch()
... | {
let config = {
let env = Environment::active().context("failed to get Rocket config")?;
Config::build(env)
.workers(1)
.finalize()
.context("failed to build Rocket config")?
};
let mut airports_source = OurAirports::init().context("failed to init OurAi... | identifier_body |
main.rs | #[macro_use]
extern crate rocket;
#[macro_use]
extern crate rocket_contrib;
mod airport_data;
mod api;
mod path;
use airport_data::our_airports::OurAirports;
use airport_data::AirportData;
use anyhow::{Context, Result};
use rocket::config::{Config, Environment};
use rocket_contrib::serve::StaticFiles;
#[rocket::mai... | ;
let airports = airports_source
.load()
.context("failed to load OurAirports data")?;
println!("finished loading OurAirports data");
rocket::custom(config)
.manage(airports)
.mount("/", StaticFiles::from("frontend/public/"))
.mount("/api", routes![api::search_routes::s... | {
println!("updating OurAirports data..");
airports_source.update().context("update failed")?;
} | conditional_block |
config.rs | // Copyright (c) 2016 Nikita Pekin and the smexybot contributors
// See the README.md 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/l... | (name: Option<&str>) -> Self {
if let Some(name) = name {
match Config::load_from_file(name) {
Ok(config) => {
return config;
},
Err(err) => warn!("Failed for load config from \"{}\": {}", name, err),
}
}
... | new | identifier_name |
config.rs | // Copyright (c) 2016 Nikita Pekin and the smexybot contributors
// See the README.md 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/l... |
}
| {
Config {
bot_name: "smexybot".to_owned(),
command_prefix: ";".to_owned(),
owners: HashSet::new(),
source_url: "https://github.com/indiv0/smexybot".to_owned(),
}
} | identifier_body |
config.rs | // Copyright (c) 2016 Nikita Pekin and the smexybot contributors
// See the README.md 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/l... | command_prefix: ";".to_owned(),
owners: HashSet::new(),
source_url: "https://github.com/indiv0/smexybot".to_owned(),
}
}
} |
impl Default for Config {
fn default() -> Config {
Config {
bot_name: "smexybot".to_owned(), | random_line_split |
coerce-unify-return.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 ... | ;
impl Foo {
fn foo<T>(self, x: T) -> Option<T> { Some(x) }
}
pub fn main() {
let _: Option<fn()> = Some(main);
let _: Option<fn()> = Foo.foo(main);
// The same two cases, with implicit type variables made explicit.
let _: Option<fn()> = Some::<_>(main);
let _: Option<fn()> = Foo.foo::<_>(main... | Foo | identifier_name |
coerce-unify-return.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 _: Option<fn()> = Foo.foo(main);
// The same two cases, with implicit type variables made explicit.
let _: Option<fn()> = Some::<_>(main);
let _: Option<fn()> = Foo.foo::<_>(main);
} | let _: Option<fn()> = Some(main); | random_line_split |
coerce-unify-return.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 ... |
}
pub fn main() {
let _: Option<fn()> = Some(main);
let _: Option<fn()> = Foo.foo(main);
// The same two cases, with implicit type variables made explicit.
let _: Option<fn()> = Some::<_>(main);
let _: Option<fn()> = Foo.foo::<_>(main);
}
| { Some(x) } | identifier_body |
parser.rs | extern crate dirs;
use regex::Regex;
use std::fs::File;
use std::io::prelude::*;
use std::path::Path;
use {Creds, Result};
pub fn get_credentials(conf: String) -> Result<Creds> {
let mut path = dirs::home_dir().ok_or("Can't get home dir")?;
// Build path to config file
path.push(conf);
let content ... | (pattern: &str, text: &str) -> Result<String> {
let re = Regex::new(pattern)?;
let cap = re.captures(text).ok_or("Couldn't match")?;
let xtr = cap.get(1).ok_or("No captures")?;
Ok(xtr.as_str().to_string())
}
fn read_config_file(path: &Path) -> Result<String> {
let mut content = String::new();
l... | extract_info | identifier_name |
parser.rs | extern crate dirs;
use regex::Regex;
use std::fs::File;
use std::io::prelude::*;
use std::path::Path;
use {Creds, Result};
pub fn get_credentials(conf: String) -> Result<Creds> {
let mut path = dirs::home_dir().ok_or("Can't get home dir")?;
// Build path to config file
path.push(conf);
let content ... | path.push(::DB);
let path_str = path.to_str()
.ok_or("Can't convert path into string")?;
Ok(path_str.to_string())
} | random_line_split | |
parser.rs | extern crate dirs;
use regex::Regex;
use std::fs::File;
use std::io::prelude::*;
use std::path::Path;
use {Creds, Result};
pub fn get_credentials(conf: String) -> Result<Creds> {
let mut path = dirs::home_dir().ok_or("Can't get home dir")?;
// Build path to config file
path.push(conf);
let content ... |
fn read_config_file(path: &Path) -> Result<String> {
let mut content = String::new();
let mut file = File::open(&path)?;
file.read_to_string(&mut content)?;
Ok(content)
}
pub fn get_db_path() -> Result<String> {
let mut path = dirs::home_dir().ok_or("Can't get home dir")?;
path.push(::DB);
... | {
let re = Regex::new(pattern)?;
let cap = re.captures(text).ok_or("Couldn't match")?;
let xtr = cap.get(1).ok_or("No captures")?;
Ok(xtr.as_str().to_string())
} | identifier_body |
ctypes.rs | // Copyright 2020 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 w... | } | random_line_split | |
ctypes.rs | // Copyright 2020 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 w... | (apis: &mut Vec<Api<FnPhase>>) {
let ctypes: HashMap<Ident, QualifiedName> = apis
.iter()
.flat_map(|api| api.deps())
.filter(|ty| known_types().is_ctype(ty))
.map(|ty| (ty.get_final_ident(), ty))
.collect();
for (id, typename) in ctypes {
apis.push(Api::CType {
... | append_ctype_information | identifier_name |
ctypes.rs | // Copyright 2020 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 w... | {
let ctypes: HashMap<Ident, QualifiedName> = apis
.iter()
.flat_map(|api| api.deps())
.filter(|ty| known_types().is_ctype(ty))
.map(|ty| (ty.get_final_ident(), ty))
.collect();
for (id, typename) in ctypes {
apis.push(Api::CType {
name: ApiName::new(&... | identifier_body | |
lexer.rs | // Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0
use crate::{errors::*, parser::syntax::make_loc, FileCommentMap, MatchedFileCommentMap};
use codespan::{ByteIndex, Span};
use move_ir_types::location::Loc;
use std::{collections::BTreeMap, fmt};
#[derive(Copy, Clone, Debug, PartialEq, ... |
pub fn advance(&mut self) -> Result<(), Error> {
self.prev_end = self.cur_end;
let text = self.text[self.cur_end..].trim_start();
self.cur_start = self.text.len() - text.len();
let (token, len) = find_token(self.file, text, self.cur_start)?;
self.cur_end = self.cur_start + ... | {
let errors = self
.doc_comments
.iter()
.map(|(span, _)| {
vec![(
Loc::new(self.file, *span),
"documentation comment cannot be matched to a language item".to_string(),
)]
})
.col... | identifier_body |
lexer.rs | // Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0
use crate::{errors::*, parser::syntax::make_loc, FileCommentMap, MatchedFileCommentMap};
use codespan::{ByteIndex, Span};
use move_ir_types::location::Loc;
use std::{collections::BTreeMap, fmt};
#[derive(Copy, Clone, Debug, PartialEq, ... | True => "true",
Use => "use",
While => "while",
LBrace => "{",
Pipe => "|",
PipePipe => "||",
RBrace => "}",
Fun => "fun",
Script => "script",
Const => "const",
Friend => "friend",
... | Spec => "spec",
Struct => "struct", | random_line_split |
lexer.rs | // Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0
use crate::{errors::*, parser::syntax::make_loc, FileCommentMap, MatchedFileCommentMap};
use codespan::{ByteIndex, Span};
use move_ir_types::location::Loc;
use std::{collections::BTreeMap, fmt};
#[derive(Copy, Clone, Debug, PartialEq, ... | (&mut self) {
let start = self.previous_end_loc() as u32;
let end = self.cur_start as u32;
let mut matched = vec![];
let merged = self
.doc_comments
.range(Span::new(start, start)..Span::new(end, end))
.map(|(span, s)| {
matched.push(*span... | match_doc_comments | identifier_name |
dhcp.rs | /* Copyright (C) 2018 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
* Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARR... |
}
fn set_event(&mut self, event: DHCPEvent) {
if let Some(tx) = self.transactions.last_mut() {
core::sc_app_layer_decoder_events_set_event_raw(
&mut tx.events, event as u8);
self.events += 1;
}
}
fn get_tx_iterator(&mut self, min_tx_id: u64, sta... | {
self.transactions.remove(index);
} | conditional_block |
dhcp.rs | /* Copyright (C) 2018 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
* Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARR... | () -> DHCPState {
return DHCPState {
tx_id: 0,
transactions: Vec::new(),
events: 0,
};
}
pub fn parse(&mut self, input: &[u8]) -> bool {
match dhcp_parse(input) {
nom::IResult::Done(_, message) => {
let malformed_options = ... | new | identifier_name |
dhcp.rs | /* Copyright (C) 2018 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
* Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARR... |
#[no_mangle]
pub extern "C" fn rs_dhcp_tx_get_logged(_state: *mut libc::c_void, tx: *mut libc::c_void) -> u32 {
let tx = cast_pointer!(tx, DHCPTransaction);
return tx.logged.get();
}
#[no_mangle]
pub extern "C" fn rs_dhcp_tx_set_logged(_state: *mut libc::c_void,
tx: *m... | {
// Just unbox...
let _drop: Box<DHCPState> = unsafe { transmute(state) };
} | identifier_body |
dhcp.rs | /* Copyright (C) 2018 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
* Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARR... |
#[no_mangle]
pub extern "C" fn rs_dhcp_state_get_events(state: *mut libc::c_void,
tx_id: libc::uint64_t)
-> *mut core::AppLayerDecoderEvents
{
let state = cast_pointer!(state, DHCPState);
match state.get_tx(tx_id) {
S... | tx: *mut libc::c_void,
logged: libc::uint32_t) {
let tx = cast_pointer!(tx, DHCPTransaction);
tx.logged.set(logged);
} | random_line_split |
extern-call.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | {
let result = fact(10u);
debug!("result = %?", result);
assert_eq!(result, 3628800u);
} | identifier_body | |
extern-call.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 ... | else {
fact(data - 1u) * data
}
}
fn fact(n: uint) -> uint {
unsafe {
debug!("n = %?", n);
rustrt::rust_dbg_call(cb, n)
}
}
pub fn main() {
let result = fact(10u);
debug!("result = %?", result);
assert_eq!(result, 3628800u);
}
| {
data
} | conditional_block |
extern-call.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 ... | (n: uint) -> uint {
unsafe {
debug!("n = %?", n);
rustrt::rust_dbg_call(cb, n)
}
}
pub fn main() {
let result = fact(10u);
debug!("result = %?", result);
assert_eq!(result, 3628800u);
}
| fact | identifier_name |
extern-call.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 ... | } else {
fact(data - 1u) * data
}
}
fn fact(n: uint) -> uint {
unsafe {
debug!("n = %?", n);
rustrt::rust_dbg_call(cb, n)
}
}
pub fn main() {
let result = fact(10u);
debug!("result = %?", result);
assert_eq!(result, 3628800u);
} | extern fn cb(data: libc::uintptr_t) -> libc::uintptr_t {
if data == 1u {
data | random_line_split |
document.rs | use common::{ApiError, Body, Credentials, Query, discovery_api};
use hyper::method::Method::{Delete, Get, Post};
use serde_json::Value;
pub fn detail(creds: &Credentials,
env_id: &str,
collection_id: &str,
document_id: &str)
-> Result<Value, ApiError> {
let p... | };
Ok(discovery_api(creds, Post, &path, q, &Body::Filename(filename))?)
} | let q = match configuration_id {
Some(id) => Query::Config(id.to_string()),
None => Query::None, | random_line_split |
document.rs | use common::{ApiError, Body, Credentials, Query, discovery_api};
use hyper::method::Method::{Delete, Get, Post};
use serde_json::Value;
pub fn | (creds: &Credentials,
env_id: &str,
collection_id: &str,
document_id: &str)
-> Result<Value, ApiError> {
let path = "/v1/environments/".to_string() + env_id + "/collections/" +
collection_id +
"/documents/" + document_id;
Ok(d... | detail | identifier_name |
document.rs | use common::{ApiError, Body, Credentials, Query, discovery_api};
use hyper::method::Method::{Delete, Get, Post};
use serde_json::Value;
pub fn detail(creds: &Credentials,
env_id: &str,
collection_id: &str,
document_id: &str)
-> Result<Value, ApiError> {
let p... | {
let path = match document_id {
Some(id) => {
"/v1/environments/".to_string() + env_id + "/collections/" +
collection_id + "/documents/" + id
}
None => {
"/v1/environments/".to_string() + env_id + "/collections/" +
collection_id + "/documents"... | identifier_body | |
ui.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/. */
//! Generic values for UI properties.
use std::fmt::{self, Write};
use style_traits::cursor::CursorKind;
use styl... |
Ok(())
}
}
/// A generic value for `scrollbar-color` property.
///
/// https://drafts.csswg.org/css-scrollbars-1/#scrollbar-color
#[derive(
Animate,
Clone,
ComputeSquaredDistance,
Copy,
Debug,
MallocSizeOf,
PartialEq,
SpecifiedValueInfo,
ToAnimatedValue,
ToAnimatedZ... | {
dest.write_str(" ")?;
x.to_css(dest)?;
dest.write_str(" ")?;
y.to_css(dest)?;
} | conditional_block |
ui.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/. */
//! Generic values for UI properties.
use std::fmt::{self, Write};
use style_traits::cursor::CursorKind;
use styl... | <W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
where
W: Write,
{
for image in &*self.images {
image.to_css(dest)?;
dest.write_str(", ")?;
}
self.keyword.to_css(dest)
}
}
/// A generic value for item of `image cursors`.
#[derive(Clone, Debug, Mallo... | to_css | identifier_name |
ui.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/. */
//! Generic values for UI properties.
use std::fmt::{self, Write};
use style_traits::cursor::CursorKind;
use styl... | ToAnimatedValue,
ToAnimatedZero,
ToComputedValue,
ToCss,
)]
pub enum ScrollbarColor<Color> {
/// `auto`
Auto,
/// `<color>{2}`
Colors {
/// First `<color>`, for color of the scrollbar thumb.
thumb: Color,
/// Second `<color>`, for color of the scrollbar track.
... | SpecifiedValueInfo, | random_line_split |
styled.rs | use super::*;
use ascii_canvas::AsciiView;
use std::fmt::{Debug, Error, Formatter};
use style::Style;
pub struct Styled {
style: Style,
content: Box<Content>,
}
impl Styled {
pub fn new(style: Style, content: Box<Content>) -> Self {
Styled {
style: style,
content: content,
... |
fn emit(&self, view: &mut AsciiView) {
self.content.emit(&mut view.styled(self.style))
}
fn into_wrap_items(self: Box<Self>, wrap_items: &mut Vec<Box<Content>>) {
let style = self.style;
super::into_wrap_items_map(self.content, wrap_items, |item| Styled::new(style, item))
}
}
... | {
self.content.min_width()
} | identifier_body |
styled.rs | use super::*;
use ascii_canvas::AsciiView;
use std::fmt::{Debug, Error, Formatter};
use style::Style;
pub struct Styled {
style: Style,
content: Box<Content>, | pub fn new(style: Style, content: Box<Content>) -> Self {
Styled {
style: style,
content: content,
}
}
}
impl Content for Styled {
fn min_width(&self) -> usize {
self.content.min_width()
}
fn emit(&self, view: &mut AsciiView) {
self.content.e... | }
impl Styled { | random_line_split |
styled.rs | use super::*;
use ascii_canvas::AsciiView;
use std::fmt::{Debug, Error, Formatter};
use style::Style;
pub struct Styled {
style: Style,
content: Box<Content>,
}
impl Styled {
pub fn new(style: Style, content: Box<Content>) -> Self {
Styled {
style: style,
content: content,
... | (&self, fmt: &mut Formatter) -> Result<(), Error> {
fmt.debug_struct("Styled")
.field("content", &self.content)
.finish()
}
}
| fmt | identifier_name |
const-impl.rs | #![feature(adt_const_params)]
#![crate_name = "foo"]
#[derive(PartialEq, Eq)]
pub enum Order {
Sorted,
Unsorted,
}
// @has foo/struct.VSet.html '//pre[@class="rust struct"]' 'pub struct VSet<T, const ORDER: Order>'
// @has foo/struct.VSet.html '//div[@id="impl-Send"]/h3[@class="code-header in-band"]' 'impl<T... | <const S: &'static str>;
// @has foo/struct.Escape.html '//div[@id="impl"]/h3[@class="code-header in-band"]' 'impl Escape<{ r#"<script>alert("Escape");</script>"# }>'
impl Escape<{ r#"<script>alert("Escape");</script>"# }> {
pub fn f() {}
}
| Escape | identifier_name |
const-impl.rs | #![feature(adt_const_params)]
#![crate_name = "foo"]
#[derive(PartialEq, Eq)]
pub enum Order {
Sorted,
Unsorted,
}
// @has foo/struct.VSet.html '//pre[@class="rust struct"]' 'pub struct VSet<T, const ORDER: Order>'
// @has foo/struct.VSet.html '//div[@id="impl-Send"]/h3[@class="code-header in-band"]' 'impl<T... | }
// @has foo/struct.VSet.html '//div[@id="impl-1"]/h3[@class="code-header in-band"]' 'impl<T> VSet<T, {Order::Unsorted}>'
impl <T> VSet<T, {Order::Unsorted}> {
pub fn new() -> Self {
Self { inner: Vec::new() }
}
}
pub struct Escape<const S: &'static str>;
// @has foo/struct.Escape.html '//div[@id="i... | impl <T> VSet<T, {Order::Sorted}> {
pub fn new() -> Self {
Self { inner: Vec::new() }
} | random_line_split |
instr_shufps.rs | use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode};
use ::RegType::*;
use ::instruction_def::*;
use ::Operand::*;
use ::Reg::*;
use ::RegScale::*;
use ::test::run_test;
#[test]
fn shufps_1() {
run_test(&Instruction { mnemonic: Mnemonic::SHUFPS, operand1: Some(Direct(XM... | () {
run_test(&Instruction { mnemonic: Mnemonic::SHUFPS, operand1: Some(Direct(XMM7)), operand2: Some(IndirectScaledIndexedDisplaced(EBX, ESI, Eight, 909533252, Some(OperandSize::Xmmword), None)), operand3: Some(Literal8(46)), operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: Non... | shufps_2 | identifier_name |
instr_shufps.rs | use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode};
use ::RegType::*;
use ::instruction_def::*;
use ::Operand::*;
use ::Reg::*;
use ::RegScale::*;
use ::test::run_test;
#[test]
fn shufps_1() {
run_test(&Instruction { mnemonic: Mnemonic::SHUFPS, operand1: Some(Direct(XM... |
#[test]
fn shufps_3() {
run_test(&Instruction { mnemonic: Mnemonic::SHUFPS, operand1: Some(Direct(XMM6)), operand2: Some(Direct(XMM1)), operand3: Some(Literal8(66)), operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[15, 198, 241, 66], OperandSize::Qwo... | {
run_test(&Instruction { mnemonic: Mnemonic::SHUFPS, operand1: Some(Direct(XMM7)), operand2: Some(IndirectScaledIndexedDisplaced(EBX, ESI, Eight, 909533252, Some(OperandSize::Xmmword), None)), operand3: Some(Literal8(46)), operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, ... | identifier_body |
instr_shufps.rs | use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode};
use ::RegType::*;
use ::instruction_def::*;
use ::Operand::*;
use ::Reg::*;
use ::RegScale::*;
use ::test::run_test;
#[test]
fn shufps_1() {
run_test(&Instruction { mnemonic: Mnemonic::SHUFPS, operand1: Some(Direct(XM... |
#[test]
fn shufps_3() {
run_test(&Instruction { mnemonic: Mnemonic::SHUFPS, operand1: Some(Direct(XMM6)), operand2: Some(Direct(XMM1)), operand3: Some(Literal8(66)), operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[15, 198, 241, 66], OperandSize::Qwor... | #[test]
fn shufps_2() {
run_test(&Instruction { mnemonic: Mnemonic::SHUFPS, operand1: Some(Direct(XMM7)), operand2: Some(IndirectScaledIndexedDisplaced(EBX, ESI, Eight, 909533252, Some(OperandSize::Xmmword), None)), operand3: Some(Literal8(46)), operand4: None, lock: false, rounding_mode: None, merge_mode: None, sa... | random_line_split |
parser.rs | use std::error::Error;
use std::fmt;
use unicode_width::UnicodeWidthStr;
#[derive(Clone)]
pub enum AST {
Output,
Input,
Loop(Vec<AST>),
Right,
Left,
Inc,
Dec,
}
#[derive(Debug)]
pub enum ParseErrorType {
UnclosedLoop,
ExtraCloseLoop,
}
use ParseErrorType::*;
#[derive(Debug)]
pub s... | b'<' => tokens.push(AST::Left),
b'[' => tokens.push(AST::Loop(_parse(code, i, level + 1)?)),
b']' => {
return if level == 0 {
Err(ParseError::new(ExtraCloseLoop, code, *i - 1))
} else {
Ok(tokens)
... |
match c {
b'+' => tokens.push(AST::Inc),
b'-' => tokens.push(AST::Dec),
b'>' => tokens.push(AST::Right), | random_line_split |
parser.rs | use std::error::Error;
use std::fmt;
use unicode_width::UnicodeWidthStr;
#[derive(Clone)]
pub enum AST {
Output,
Input,
Loop(Vec<AST>),
Right,
Left,
Inc,
Dec,
}
#[derive(Debug)]
pub enum ParseErrorType {
UnclosedLoop,
ExtraCloseLoop,
}
use ParseErrorType::*;
#[derive(Debug)]
pub s... | {
err: ParseErrorType,
line: Vec<u8>,
linenum: usize,
offset: usize,
}
impl ParseError {
fn new(err: ParseErrorType, code: &[u8], i: usize) -> Self {
let (line, linenum, offset) = find_line(code, i);
Self {
err,
line: line.into(),
linenum,
... | ParseError | identifier_name |
parser.rs | use std::error::Error;
use std::fmt;
use unicode_width::UnicodeWidthStr;
#[derive(Clone)]
pub enum AST {
Output,
Input,
Loop(Vec<AST>),
Right,
Left,
Inc,
Dec,
}
#[derive(Debug)]
pub enum ParseErrorType {
UnclosedLoop,
ExtraCloseLoop,
}
use ParseErrorType::*;
#[derive(Debug)]
pub s... |
}
fn find_line(code: &[u8], i: usize) -> (&[u8], usize, usize) {
let offset = code[0..i].iter().rev().take_while(|x| **x!= b'\n').count();
let end = i + code[i..].iter().take_while(|x| **x!= b'\n').count();
let linenum = code[0..(i - offset)]
.iter()
.filter(|x| **x == b'\n')
.count()... | {
Ok(tokens)
} | conditional_block |
parser.rs | use std::error::Error;
use std::fmt;
use unicode_width::UnicodeWidthStr;
#[derive(Clone)]
pub enum AST {
Output,
Input,
Loop(Vec<AST>),
Right,
Left,
Inc,
Dec,
}
#[derive(Debug)]
pub enum ParseErrorType {
UnclosedLoop,
ExtraCloseLoop,
}
use ParseErrorType::*;
#[derive(Debug)]
pub s... |
fn _parse(code: &[u8], i: &mut usize, level: u32) -> Result<Vec<AST>, ParseError> {
// Starting [ of the loop
let start = i.saturating_sub(1);
let mut tokens = Vec::new();
while let Some(c) = code.get(*i) {
*i += 1;
match c {
b'+' => tokens.push(AST::Inc),
b'-... | {
let mut i = 0;
_parse(code, &mut i, 0)
} | identifier_body |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.