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 |
|---|---|---|---|---|
main.rs | mod tokenizer;
mod executor;
use tokenizer::*;
use executor::{execute, Numeric};
use std::collections::HashMap;
use std::io::prelude::*;
use std::io;
fn main() {
// contain all program variables
let mut variables: HashMap<String, executor::Numeric> = HashMap::new();
// string to execute
let mut buffer ... |
// clean string
buffer.clear();
}
}
| {
break;
} | conditional_block |
needless_borrow.rs | // run-rustfix | *y
}
#[warn(clippy::all, clippy::needless_borrow)]
#[allow(unused_variables)]
fn main() {
let a = 5;
let b = x(&a);
let c = x(&&a);
let s = &String::from("hi");
let s_ident = f(&s); // should not error, because `&String` implements Copy, but `String` does not
let g_val = g(&Vec::new()); // ... |
#![allow(clippy::needless_borrowed_reference)]
fn x(y: &i32) -> i32 { | random_line_split |
needless_borrow.rs | // run-rustfix
#![allow(clippy::needless_borrowed_reference)]
fn x(y: &i32) -> i32 {
*y
}
#[warn(clippy::all, clippy::needless_borrow)]
#[allow(unused_variables)]
fn main() {
let a = 5;
let b = x(&a);
let c = x(&&a);
let s = &String::from("hi");
let s_ident = f(&s); // should not error, becau... | (y: &[u8]) -> u8 {
y[0]
}
trait Trait {}
impl<'a> Trait for &'a str {}
fn h(_: &dyn Trait) {}
| g | identifier_name |
needless_borrow.rs | // run-rustfix
#![allow(clippy::needless_borrowed_reference)]
fn x(y: &i32) -> i32 {
*y
}
#[warn(clippy::all, clippy::needless_borrow)]
#[allow(unused_variables)]
fn main() |
fn f<T: Copy>(y: &T) -> T {
*y
}
fn g(y: &[u8]) -> u8 {
y[0]
}
trait Trait {}
impl<'a> Trait for &'a str {}
fn h(_: &dyn Trait) {}
| {
let a = 5;
let b = x(&a);
let c = x(&&a);
let s = &String::from("hi");
let s_ident = f(&s); // should not error, because `&String` implements Copy, but `String` does not
let g_val = g(&Vec::new()); // should not error, because `&Vec<T>` derefs to `&[T]`
let vec = Vec::new();
let vec_va... | identifier_body |
graph.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!(counter < expected_incoming.len());
debug!("counter=%? expected=%? edge_index=%? edge=%?",
counter, expected_incoming[counter], edge_index, edge);
match expected_incoming[counter] {
(ref e, ref n) => {
assert_eq!(e, &edge... | do graph.each_incoming_edge(start_index) |edge_index, edge| {
assert_eq!(graph.edge_data(edge_index), &edge.data); | random_line_split |
graph.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 ... | (&self) -> NodeIndex {
self.source
}
pub fn target(&self) -> NodeIndex {
self.target
}
}
#[cfg(test)]
mod test {
use middle::graph::*;
type TestNode = Node<&'static str>;
type TestEdge = Edge<&'static str>;
type TestGraph = Graph<&'static str, &'static str>;
fn create... | source | identifier_name |
graph.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
pub fn edge_data<'a>(&'a self, idx: EdgeIndex) -> &'a E {
&self.edges[*idx].data
}
pub fn edge<'a>(&'a self, idx: EdgeIndex) -> &'a Edge<E> {
&self.edges[*idx]
}
pub fn first_adjacent(&self, node: NodeIndex, dir: Direction) -> EdgeIndex {
//! Accesses the index of the fir... | {
&mut self.edges[*idx].data
} | identifier_body |
type_allocation_places.rs | #![allow(dead_code)]
use crate::config::MovableTypesHookOutput;
use crate::cpp_data::{CppItem, CppPath};
use crate::cpp_type::{CppPointerLikeTypeKind, CppType};
use crate::processor::ProcessorData;
use log::{info, trace};
use ritual_common::errors::Result;
use std::collections::HashMap;
#[derive(Default, Debug)]
stru... |
CppType::PointerLike { kind, target,.. } => {
check_type(
target,
*kind == CppPointerLikeTypeKind::Pointer,
data_map,
item_text,
);
}
_ => {}
}
}
const MAX_ITEMS: usize = 10;
/// Detects the preferred ... | {
let good_path = path.deinstantiate();
if let Some(stats) = data_map.get_mut(&good_path) {
if is_behind_pointer {
if stats.pointer_encounters.len() < MAX_ITEMS {
stats.pointer_encounters.push(item_text.to_string());
... | conditional_block |
type_allocation_places.rs | #![allow(dead_code)]
use crate::config::MovableTypesHookOutput;
use crate::cpp_data::{CppItem, CppPath};
use crate::cpp_type::{CppPointerLikeTypeKind, CppType};
use crate::processor::ProcessorData;
use log::{info, trace};
use ritual_common::errors::Result;
use std::collections::HashMap;
#[derive(Default, Debug)]
stru... | (data_map: &HashMap<CppPath, TypeStats>) {
for (name, stats) in data_map {
trace!("type = {}; stats = {:?}", name.to_cpp_pseudo_code(), stats);
}
for (path, stats) in data_map {
let suggestion = if stats.virtual_functions.is_empty() {
if stats.pointer_encounters.is_empty() {
... | log_results | identifier_name |
type_allocation_places.rs | #![allow(dead_code)]
use crate::config::MovableTypesHookOutput;
use crate::cpp_data::{CppItem, CppPath};
use crate::cpp_type::{CppPointerLikeTypeKind, CppType};
use crate::processor::ProcessorData;
use log::{info, trace};
use ritual_common::errors::Result;
use std::collections::HashMap;
#[derive(Default, Debug)]
stru... | }
info!("* pointer_encounters ({}):", stats.pointer_encounters.len());
for item in &stats.pointer_encounters {
info!("* * {}", item);
}
info!(
"* non_pointer_encounters ({}):",
stats.non_pointer_encounters.len()
);
for item in &... | for item in &stats.virtual_functions {
info!("* * {}", item); | random_line_split |
type_allocation_places.rs | #![allow(dead_code)]
use crate::config::MovableTypesHookOutput;
use crate::cpp_data::{CppItem, CppPath};
use crate::cpp_type::{CppPointerLikeTypeKind, CppType};
use crate::processor::ProcessorData;
use log::{info, trace};
use ritual_common::errors::Result;
use std::collections::HashMap;
#[derive(Default, Debug)]
stru... | CppType::PointerLike { kind, target,.. } => {
check_type(
target,
*kind == CppPointerLikeTypeKind::Pointer,
data_map,
item_text,
);
}
_ => {}
}
}
const MAX_ITEMS: usize = 10;
/// Detects the preferred ... | {
match cpp_type {
CppType::Class(path) => {
let good_path = path.deinstantiate();
if let Some(stats) = data_map.get_mut(&good_path) {
if is_behind_pointer {
if stats.pointer_encounters.len() < MAX_ITEMS {
stats.pointer_enco... | identifier_body |
join_room_by_id_or_alias.rs | //! [POST /_matrix/client/r0/join/{roomIdOrAlias}](https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-join-roomidoralias)
use ruma_api::ruma_api;
use ruma_identifiers::{RoomId, RoomIdOrAliasId};
use super::ThirdPartySigned;
ruma_api! {
metadata {
description: "Join a room using its I... | /// The room where the user should be invited.
#[ruma_api(path)]
pub room_id_or_alias: RoomIdOrAliasId,
/// The servers to attempt to join the room through. One of the servers
/// must be participating in the room.
#[ruma_api(query)]
#[serde(default)]
pub... | rate_limited: true,
requires_authentication: true,
}
request { | random_line_split |
lib.rs | // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
use session::Session;
use lint::LintId;
mod builtin;
/// Tell the `LintStore` about all the built-in lints (the ones
/// defined in this crate and the ones defined in
/// `rustc::lint::builtin`).
pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
macro_rules! add_builtin {
($... | pub use rustc::middle as middle;
pub use rustc::session as session;
pub use rustc::util as util; | random_line_split |
lib.rs | // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | )
}
add_builtin!(sess,
HardwiredLints,
WhileTrue,
ImproperCTypes,
BoxPointers,
UnusedAttributes,
PathStatements,
UnusedResults,
NonCamelCaseTypes,
... | {
macro_rules! add_builtin {
($sess:ident, $($name:ident),*,) => (
{$(
store.register_pass($sess, false, box builtin::$name);
)*}
)
}
macro_rules! add_builtin_with_new {
($sess:ident, $($name:ident),*,) => (
{$(
... | identifier_body |
lib.rs | // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | (store: &mut lint::LintStore, sess: Option<&Session>) {
macro_rules! add_builtin {
($sess:ident, $($name:ident),*,) => (
{$(
store.register_pass($sess, false, box builtin::$name);
)*}
)
}
macro_rules! add_builtin_with_new {
($sess:iden... | register_builtins | identifier_name |
the_test.rs | use std::env;
use std::process;
use std::sync::Arc;
fn main() {
log_ndc_env_logger::init();
let mut server = httpbis::ServerBuilder::new_plain();
server
.service
.set_service("/", Arc::new(httpbis_h2spec_test::Ok200));
server.set_port(8888);
let _server = server.build().expect("serve... | .stderr(process::Stdio::inherit())
.spawn()
.expect("spawn h2spec");
let exit_status = h2spec.wait().expect("h2spec wait");
assert!(exit_status.success(), "{}", exit_status);
} | .stdin(process::Stdio::null())
.stdout(process::Stdio::inherit()) | random_line_split |
the_test.rs | use std::env;
use std::process;
use std::sync::Arc;
fn | () {
log_ndc_env_logger::init();
let mut server = httpbis::ServerBuilder::new_plain();
server
.service
.set_service("/", Arc::new(httpbis_h2spec_test::Ok200));
server.set_port(8888);
let _server = server.build().expect("server.build()");
let mut h2spec = process::Command::new("h2... | main | identifier_name |
the_test.rs | use std::env;
use std::process;
use std::sync::Arc;
fn main() | assert!(exit_status.success(), "{}", exit_status);
}
| {
log_ndc_env_logger::init();
let mut server = httpbis::ServerBuilder::new_plain();
server
.service
.set_service("/", Arc::new(httpbis_h2spec_test::Ok200));
server.set_port(8888);
let _server = server.build().expect("server.build()");
let mut h2spec = process::Command::new("h2s... | identifier_body |
mod.rs | mod compile_mx;
pub mod cpp;
pub mod paths;
mod template;
use crate::error::Result;
use crate::generate::cpp::modeler::MxModeler;
use crate::generate::paths::Paths;
use crate::model::create::Create;
use crate::model::creator::Creator;
use crate::model::post_process::PostProcess;
use crate::model::transform::Transform;... | (args: GenArgs) -> Result<()> {
let xsd = read_to_string(&args.paths.xsd_3_0).unwrap();
let doc = exile::parse(xsd.as_str()).unwrap();
let new_xsd = Xsd::load(&args.paths.xsd_3_0)?;
let transforms: Vec<Box<dyn Transform>> = vec![Box::new(MxModeler::new())];
let creates: Vec<Box<dyn Create>> = vec![B... | run | identifier_name |
mod.rs | mod compile_mx;
pub mod cpp;
pub mod paths;
mod template;
use crate::error::Result;
use crate::generate::cpp::modeler::MxModeler;
use crate::generate::paths::Paths;
use crate::model::create::Create;
use crate::model::creator::Creator;
use crate::model::post_process::PostProcess;
use crate::model::transform::Transform;... |
}
/// Generate `mx::core` in C++
pub fn run(args: GenArgs) -> Result<()> {
let xsd = read_to_string(&args.paths.xsd_3_0).unwrap();
let doc = exile::parse(xsd.as_str()).unwrap();
let new_xsd = Xsd::load(&args.paths.xsd_3_0)?;
let transforms: Vec<Box<dyn Transform>> = vec![Box::new(MxModeler::new())];
... | {
Self {
paths: Paths::default(),
}
} | identifier_body |
mod.rs | mod compile_mx;
pub mod cpp;
pub mod paths;
mod template;
use crate::error::Result;
use crate::generate::cpp::modeler::MxModeler;
use crate::generate::paths::Paths;
use crate::model::create::Create;
use crate::model::creator::Creator;
use crate::model::post_process::PostProcess;
use crate::model::transform::Transform;... | let creates: Vec<Box<dyn Create>> = vec![Box::new(MxModeler::new())];
let post_processors: Vec<Box<dyn PostProcess>> = vec![Box::new(MxModeler::new())];
let creator = Creator::new_with_default(Some(transforms), Some(creates), Some(post_processors));
let models = creator.create(&new_xsd)?;
let cpp_wr... | random_line_split | |
cdgdec.rs | // Copyright (C) 2019 Guillaume Desmottes <guillaume.desmottes@collabora.com>
//
// 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, ... | () {
init();
let pipeline = gst::Pipeline::new(Some("cdgdec-test"));
let input_path = {
let mut r = PathBuf::new();
r.push(env!("CARGO_MANIFEST_DIR"));
r.push("tests");
r.push("BrotherJohn");
r.set_extension("cdg");
r
};
// Ensure we are in push mod... | test_cdgdec | identifier_name |
cdgdec.rs | // Copyright (C) 2019 Guillaume Desmottes <guillaume.desmottes@collabora.com>
//
// 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, ... | child_proxy
.set_child_property("real-filesrc::blocksize", &blocksize)
.expect("failed to set 'blocksize' property");
}
let parse = gst::ElementFactory::make("cdgparse", None).unwrap();
let dec = gst::ElementFactory::make("cdgdec", None).unwrap();
let sink = gst::ElementFa... | .expect("failed to set 'num-buffers' property");
let blocksize: u32 = 24; // One CDG instruction | random_line_split |
cdgdec.rs | // Copyright (C) 2019 Guillaume Desmottes <guillaume.desmottes@collabora.com>
//
// 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, ... |
#[test]
fn test_cdgdec() {
init();
let pipeline = gst::Pipeline::new(Some("cdgdec-test"));
let input_path = {
let mut r = PathBuf::new();
r.push(env!("CARGO_MANIFEST_DIR"));
r.push("tests");
r.push("BrotherJohn");
r.set_extension("cdg");
r
};
// E... | {
use std::sync::Once;
static INIT: Once = Once::new();
INIT.call_once(|| {
gst::init().unwrap();
gstcdg::plugin_register_static().expect("cdgdec tests");
});
} | identifier_body |
a.rs | /*
* Copyright (C) 2015 Benjamin Fry <benjaminfry@me.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by ap... | {
let address: Ipv4Addr = tokens
.next()
.ok_or_else(|| ParseError::from(ParseErrorKind::MissingToken("ipv4 address".to_string())))
.and_then(|s| Ipv4Addr::from_str(s).map_err(Into::into))?;
Ok(address)
} | identifier_body | |
a.rs | /*
* Copyright (C) 2015 Benjamin Fry <benjaminfry@me.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by ap... |
use std::net::Ipv4Addr;
use std::str::FromStr;
use crate::error::*;
/// Parse the RData from a set of Tokens
pub fn parse<'i, I: Iterator<Item = &'i str>>(mut tokens: I) -> ParseResult<Ipv4Addr> {
let address: Ipv4Addr = tokens
.next()
.ok_or_else(|| ParseError::from(ParseErrorKind::MissingToken("i... | //! Parser for A text form | random_line_split |
a.rs | /*
* Copyright (C) 2015 Benjamin Fry <benjaminfry@me.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by ap... | <'i, I: Iterator<Item = &'i str>>(mut tokens: I) -> ParseResult<Ipv4Addr> {
let address: Ipv4Addr = tokens
.next()
.ok_or_else(|| ParseError::from(ParseErrorKind::MissingToken("ipv4 address".to_string())))
.and_then(|s| Ipv4Addr::from_str(s).map_err(Into::into))?;
Ok(address)
}
| parse | identifier_name |
lower_caser.rs | use super::{Token, TokenFilter, TokenStream};
use crate::tokenizer::BoxTokenStream;
use std::mem;
impl TokenFilter for LowerCaser {
fn transform<'a>(&self, token_stream: BoxTokenStream<'a>) -> BoxTokenStream<'a> {
BoxTokenStream::from(LowerCaserTokenStream {
tail: token_stream,
buff... | (&mut self) -> bool {
if!self.tail.advance() {
return false;
}
if self.token_mut().text.is_ascii() {
// fast track for ascii.
self.token_mut().text.make_ascii_lowercase();
} else {
to_lowercase_unicode(&mut self.tail.token_mut().text, &mut ... | advance | identifier_name |
lower_caser.rs | use super::{Token, TokenFilter, TokenStream};
use crate::tokenizer::BoxTokenStream;
use std::mem;
impl TokenFilter for LowerCaser {
fn transform<'a>(&self, token_stream: BoxTokenStream<'a>) -> BoxTokenStream<'a> {
BoxTokenStream::from(LowerCaserTokenStream {
tail: token_stream,
buff... | }
true
}
fn token(&self) -> &Token {
self.tail.token()
}
fn token_mut(&mut self) -> &mut Token {
self.tail.token_mut()
}
}
#[cfg(test)]
mod tests {
use crate::tokenizer::tests::assert_token;
use crate::tokenizer::{LowerCaser, SimpleTokenizer, TextAnalyzer, ... | to_lowercase_unicode(&mut self.tail.token_mut().text, &mut self.buffer);
mem::swap(&mut self.tail.token_mut().text, &mut self.buffer); | random_line_split |
lower_caser.rs | use super::{Token, TokenFilter, TokenStream};
use crate::tokenizer::BoxTokenStream;
use std::mem;
impl TokenFilter for LowerCaser {
fn transform<'a>(&self, token_stream: BoxTokenStream<'a>) -> BoxTokenStream<'a> {
BoxTokenStream::from(LowerCaserTokenStream {
tail: token_stream,
buff... |
}
#[cfg(test)]
mod tests {
use crate::tokenizer::tests::assert_token;
use crate::tokenizer::{LowerCaser, SimpleTokenizer, TextAnalyzer, Token};
#[test]
fn test_to_lower_case() {
let tokens = token_stream_helper("Tree");
assert_eq!(tokens.len(), 1);
assert_token(&tokens[0], 0, ... | {
self.tail.token_mut()
} | identifier_body |
lower_caser.rs | use super::{Token, TokenFilter, TokenStream};
use crate::tokenizer::BoxTokenStream;
use std::mem;
impl TokenFilter for LowerCaser {
fn transform<'a>(&self, token_stream: BoxTokenStream<'a>) -> BoxTokenStream<'a> {
BoxTokenStream::from(LowerCaserTokenStream {
tail: token_stream,
buff... |
true
}
fn token(&self) -> &Token {
self.tail.token()
}
fn token_mut(&mut self) -> &mut Token {
self.tail.token_mut()
}
}
#[cfg(test)]
mod tests {
use crate::tokenizer::tests::assert_token;
use crate::tokenizer::{LowerCaser, SimpleTokenizer, TextAnalyzer, Token};
... | {
to_lowercase_unicode(&mut self.tail.token_mut().text, &mut self.buffer);
mem::swap(&mut self.tail.token_mut().text, &mut self.buffer);
} | conditional_block |
simple_executor.rs | use crate::task::Task;
use alloc::collections::VecDeque;
use core::task::{RawWaker, RawWakerVTable, Waker};
pub struct SimpleExecutor {
task_queue: VecDeque<Task>, | task_queue: VecDeque::new(),
}
}
pub fn spawn(&mut self, task: Task) { self.task_queue.push_back(task) }
}
fn dummy_raw_waker() -> RawWaker {
fn no_op(_: *const ()) {}
fn clone(_: *const ()) -> RawWaker { dummy_raw_waker() }
let vtable = &RawWakerVTable::new(clone, no_op, no_o... | }
impl SimpleExecutor {
pub fn new() -> SimpleExecutor {
SimpleExecutor { | random_line_split |
simple_executor.rs | use crate::task::Task;
use alloc::collections::VecDeque;
use core::task::{RawWaker, RawWakerVTable, Waker};
pub struct SimpleExecutor {
task_queue: VecDeque<Task>,
}
impl SimpleExecutor {
pub fn new() -> SimpleExecutor {
SimpleExecutor {
task_queue: VecDeque::new(),
}
}
pu... | () -> RawWaker {
fn no_op(_: *const ()) {}
fn clone(_: *const ()) -> RawWaker { dummy_raw_waker() }
let vtable = &RawWakerVTable::new(clone, no_op, no_op, no_op);
RawWaker::new(0 as *const (), vtable)
}
fn dummy_waker() -> Waker { unsafe { Waker::from_raw(dummy_raw_waker()) } }
| dummy_raw_waker | identifier_name |
simple_executor.rs | use crate::task::Task;
use alloc::collections::VecDeque;
use core::task::{RawWaker, RawWakerVTable, Waker};
pub struct SimpleExecutor {
task_queue: VecDeque<Task>,
}
impl SimpleExecutor {
pub fn new() -> SimpleExecutor |
pub fn spawn(&mut self, task: Task) { self.task_queue.push_back(task) }
}
fn dummy_raw_waker() -> RawWaker {
fn no_op(_: *const ()) {}
fn clone(_: *const ()) -> RawWaker { dummy_raw_waker() }
let vtable = &RawWakerVTable::new(clone, no_op, no_op, no_op);
RawWaker::new(0 as *const (), vtable)
}
... | {
SimpleExecutor {
task_queue: VecDeque::new(),
}
} | identifier_body |
lib.rs | // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
let krate = match parse_input(input, &parse_session) {
Ok(krate) => krate,
Err(diagnostic) => {
if let Some(mut diagnostic) = diagnostic {
diagnostic.emit();
}
summary.add_parsing_error();
return Ok((summary, FileMap::new(), FormatRepo... | let main_file = match input {
Input::File(ref file) => file.clone(),
Input::Text(..) => PathBuf::from("stdin"),
}; | random_line_split |
lib.rs | // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | (&self) -> bool {
self.warning_count() > 0
}
}
impl fmt::Display for FormatReport {
// Prints all the formatting errors.
fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> {
for (file, errors) in &self.file_error_map {
for error in errors {
try!(wr... | has_warnings | identifier_name |
lib.rs | // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
}
impl Spanned for ast::Ty {
fn span(&self) -> Span {
self.span
}
}
impl Spanned for ast::Arg {
fn span(&self) -> Span {
if items::is_named_arg(self) {
mk_sp(self.pat.span.lo, self.ty.span.hi)
} else {
self.ty.span
}
}
}
#[derive(Copy, Clone, D... | {
self.span
} | identifier_body |
font.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/. */
/// Implementation of Quartz (CoreGraphics) fonts.
use app_units::Au;
use byteorder::{BigEndian, ByteOrder};
use c... | None => Err(()),
}
}
fn template(&self) -> Arc<FontTemplateData> {
self.font_data.clone()
}
fn family_name(&self) -> Option<String> {
Some(self.ctfont.family_name())
}
fn face_name(&self) -> Option<String> {
Some(self.ctfont.face_name())
}
... | {
let size = match pt_size {
Some(s) => s.to_f64_px(),
None => 0.0,
};
match template.ctfont(size) {
Some(ref ctfont) => {
let mut handle = FontHandle {
font_data: template.clone(),
ctfont: ctfont.clone_w... | identifier_body |
font.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/. */
/// Implementation of Quartz (CoreGraphics) fonts.
use app_units::Au;
use byteorder::{BigEndian, ByteOrder};
use c... | // see also: https://bugreports.qt-project.org/browse/QTBUG-13364
underline_offset: au_from_pt(self.ctfont.underline_position() as f64),
strikeout_size: Au(0), // FIXME(Issue #942)
strikeout_offset: Au(0), // FIXME(Issue #942)
leading: au_from_pt(leading),
... | // see also: https://bugs.webkit.org/show_bug.cgi?id=16768 | random_line_split |
font.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/. */
/// Implementation of Quartz (CoreGraphics) fonts.
use app_units::Au;
use byteorder::{BigEndian, ByteOrder};
use c... | (pt: f64) -> Au {
Au::from_f64_px(pt_to_px(pt))
}
impl FontTable {
pub fn wrap(data: CFData) -> FontTable {
FontTable { data: data }
}
}
impl FontTableMethods for FontTable {
fn buffer(&self) -> &[u8] {
self.data.bytes()
}
}
#[derive(Debug)]
pub struct FontHandle {
font_data: ... | au_from_pt | identifier_name |
main.rs | // Copyright 2017 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable... | break;
}
}
}
}
fn main() {
let (mut worker, tx, rx) = Worker::create(1024);
/*
let module = Box::new(modules::ConstCtrl::new(440.0f32.log2()));
worker.handle_node(Node::create(module, 1, [], []));
let module = Box::new(modules::Sin::new(44_100.0));
worke... | self.cur_note = if on { Some(midi_num) } else { None }
}
i += 3;
} else { | random_line_split |
main.rs | // Copyright 2017 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable... | (&self, msg: Message) {
self.tx.send(msg);
}
fn set_ctrl_const(&mut self, value: u8, lo: f32, hi: f32, ix: usize, ts: u64) {
let value = lo + value as f32 * (1.0/127.0) * (hi - lo);
let param = SetParam {
ix: ix,
param_ix: 0,
val: value,
t... | send | identifier_name |
main.rs | // Copyright 2017 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable... | else if data[i] == 0x90 || data[i] == 0x80 {
let midi_num = data[i + 1];
let velocity = data[i + 2];
let on = data[i] == 0x90 && velocity > 0;
if on || self.cur_note == Some(midi_num) {
self.send_note(vec![5, 7], midi_num as f32, veloc... | {
let controller = data[i + 1];
let value = data[i + 2];
match controller {
1 => self.set_ctrl_const(value, 0.0, 22_000f32.log2(), 3, ts),
2 => self.set_ctrl_const(value, 0.0, 0.995, 4, ts),
3 => self.set_ctrl_co... | conditional_block |
movedex.rs | extern crate csv;
use super::enums;
use super::moves::Technique;
use enum_primitive::FromPrimitive;
use std::collections::HashMap;
/// Manages the list of moves that are available. Contains a bool that is true whenever all
/// available moves are inside the entries to make an easier search possible.
/// By now the ... | move_tmp.clone().unwrap().get_name() == "fling" ||
move_tmp.clone().unwrap().get_name() == "trump-card" ||
move_tmp.clone().unwrap().get_name() == "me-first" ||
move_tmp.clone().unwrap().get_category() == enums::MoveCategory::Unique) ||... | {
let mut new_dex = Vec::new();
let mut move_db = csv::Reader::from_file("./src/db/tables/pokemon_moves.csv").unwrap();
for record in move_db.decode() {
let (poke_id, version, move_id, _, move_level, _): (usize,
u8,
... | identifier_body |
movedex.rs | extern crate csv;
use super::enums;
use super::moves::Technique;
use enum_primitive::FromPrimitive;
use std::collections::HashMap;
/// Manages the list of moves that are available. Contains a bool that is true whenever all
/// available moves are inside the entries to make an easier search possible.
/// By now the ... |
}
Movedex {
entries: moves,
complete: true,
}
}
}
| {
if !(id == last_id) {
moves[last_id - 1].set_flags(flags);
last_id = id;
flags = Vec::new();
}
flags.push(enums::MoveFlags::from_i32(identifier).unwrap());
} | conditional_block |
movedex.rs | extern crate csv;
use super::enums;
use super::moves::Technique;
use enum_primitive::FromPrimitive;
use std::collections::HashMap;
/// Manages the list of moves that are available. Contains a bool that is true whenever all
/// available moves are inside the entries to make an easier search possible.
/// By now the ... | {
entries: Vec<Technique>,
complete: bool,
}
// TODO: last 4 attacks are missing in move_meta.csv, therefore are not implemented right now.
// DB must be extended and if statements adjusted accordingly
impl Movedex {
/// Takes an ID and a movedex and returns an option with the move that can be find with ... | Movedex | identifier_name |
movedex.rs | extern crate csv;
use super::enums;
use super::moves::Technique;
use enum_primitive::FromPrimitive;
use std::collections::HashMap;
/// Manages the list of moves that are available. Contains a bool that is true whenever all
/// available moves are inside the entries to make an easier search possible.
/// By now the ... | }
/// Returns a list of all learnable moves by level for a specific pokemon with a specific
/// level.
pub fn for_token(&self, level: u16, id: usize) -> Movedex {
let mut new_dex = Vec::new();
let mut move_db = csv::Reader::from_file("./src/db/tables/pokemon_moves.csv").unwrap();
... | None | random_line_split |
new_task.rs | use lapin::{options::*, types::FieldTable, BasicProperties, Connection, ConnectionProperties};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let args: Vec<_> = std::env::args().skip(1).collect();
let message = match args.len() {
0 => b"hello".to_vec(),
_ => args.joi... | } | random_line_split | |
new_task.rs | use lapin::{options::*, types::FieldTable, BasicProperties, Connection, ConnectionProperties};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> | .basic_publish(
"",
"task_queue",
BasicPublishOptions::default(),
message.clone(),
BasicProperties::default(),
)
.await?;
println!(" [x] Sent {:?}", std::str::from_utf8(&message)?);
conn.close(0, "").await?;
Ok(())
}
| {
let args: Vec<_> = std::env::args().skip(1).collect();
let message = match args.len() {
0 => b"hello".to_vec(),
_ => args.join(" ").into_bytes(),
};
let addr = "amqp://127.0.0.1:5672";
let conn = Connection::connect(addr, ConnectionProperties::default()).await?;
let channel = ... | identifier_body |
new_task.rs | use lapin::{options::*, types::FieldTable, BasicProperties, Connection, ConnectionProperties};
#[tokio::main]
async fn | () -> Result<(), Box<dyn std::error::Error>> {
let args: Vec<_> = std::env::args().skip(1).collect();
let message = match args.len() {
0 => b"hello".to_vec(),
_ => args.join(" ").into_bytes(),
};
let addr = "amqp://127.0.0.1:5672";
let conn = Connection::connect(addr, ConnectionProp... | main | identifier_name |
lib.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 ... |
#[no_mangle]
pub unsafe extern "C" fn memmove(dest: *mut u8, src: *u8, n: uint) -> *mut u8 {
if src < dest as *u8 { // copy from end
let mut i = n;
while i!= 0 {
i -= 1;
*(offset(dest as *u8, i as int) as *mut u8) = *offset(src, i as int);
}
} else { // copy from... | *(offset(dest as *u8, i as int) as *mut u8) = *offset(src, i as int);
i += 1;
}
return dest;
} | random_line_split |
lib.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 ... |
return dest;
}
#[no_mangle]
pub unsafe extern "C" fn memset(s: *mut u8, c: i32, n: uint) -> *mut u8 {
let mut i = 0;
while i < n {
*(offset(s as *u8, i as int) as *mut u8) = c as u8;
i += 1;
}
return s;
}
#[no_mangle]
pub unsafe extern "C" fn memcmp(s1: *u8, s2: *u8, n: uint) -> i... | { // copy from beginning
let mut i = 0;
while i < n {
*(offset(dest as *u8, i as int) as *mut u8) = *offset(src, i as int);
i += 1;
}
} | conditional_block |
lib.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 ... |
#[test] fn work_on_windows() { } // FIXME #10872 needed for a happy windows
| {
let mut i = 0;
while i < n {
let a = *offset(s1, i as int);
let b = *offset(s2, i as int);
if a != b {
return (a - b) as i32
}
i += 1;
}
return 0;
} | identifier_body |
lib.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 ... | (dest: *mut u8, src: *u8, n: uint) -> *mut u8 {
if src < dest as *u8 { // copy from end
let mut i = n;
while i!= 0 {
i -= 1;
*(offset(dest as *u8, i as int) as *mut u8) = *offset(src, i as int);
}
} else { // copy from beginning
let mut i = 0;
whil... | memmove | identifier_name |
clock.rs | use std::fmt;
use std::sync::{Arc, Condvar, Mutex};
use std::thread;
use std::time::{Duration, Instant};
pub struct Clock {
init: isize,
time_left: Arc<Mutex<isize>>,
running: Arc<Mutex<bool>>,
}
fn spawn_updater_thread(
time_left: Arc<Mutex<isize>>,
running: Arc<Mutex<bool>>,
main_signal: Arc... | });
}
impl Clock {
// starts stopped
pub fn new(init: isize, main_signal: Arc<Condvar>) -> Clock {
let time_left = Arc::new(Mutex::new(init));
let running = Arc::new(Mutex::new(false));
spawn_updater_thread(time_left.clone(), running.clone(), main_signal);
Clock {
... | let sleep_start = Instant::now();
thread::sleep(Duration::from_millis(10));
let slept_for = Instant::now().duration_since(sleep_start);
*time_left.lock().unwrap() -= slept_for.subsec_nanos() as isize / 10000000; | random_line_split |
clock.rs | use std::fmt;
use std::sync::{Arc, Condvar, Mutex};
use std::thread;
use std::time::{Duration, Instant};
pub struct Clock {
init: isize,
time_left: Arc<Mutex<isize>>,
running: Arc<Mutex<bool>>,
}
fn spawn_updater_thread(
time_left: Arc<Mutex<isize>>,
running: Arc<Mutex<bool>>,
main_signal: Arc... |
if *time_left.lock().unwrap() <= 0 {
main_signal.notify_all();
}
let sleep_start = Instant::now();
thread::sleep(Duration::from_millis(10));
let slept_for = Instant::now().duration_since(sleep_start);
*time_left.lock().unwrap() -= slept_for.subsec_nanos() as ... | {
thread::sleep(Duration::from_millis(10));
continue;
} | conditional_block |
clock.rs | use std::fmt;
use std::sync::{Arc, Condvar, Mutex};
use std::thread;
use std::time::{Duration, Instant};
pub struct Clock {
init: isize,
time_left: Arc<Mutex<isize>>,
running: Arc<Mutex<bool>>,
}
fn spawn_updater_thread(
time_left: Arc<Mutex<isize>>,
running: Arc<Mutex<bool>>,
main_signal: Arc... |
pub fn time_remaining(&self) -> isize {
*self.time_left.lock().unwrap()
}
}
impl fmt::Display for Clock {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let csecs = self.time_remaining();
let secs = csecs / 100;
if secs <= 0 {
let min = -secs / 60;
... | {
*self.running.lock().unwrap() = true;
} | identifier_body |
clock.rs | use std::fmt;
use std::sync::{Arc, Condvar, Mutex};
use std::thread;
use std::time::{Duration, Instant};
pub struct Clock {
init: isize,
time_left: Arc<Mutex<isize>>,
running: Arc<Mutex<bool>>,
}
fn spawn_updater_thread(
time_left: Arc<Mutex<isize>>,
running: Arc<Mutex<bool>>,
main_signal: Arc... | (&self, f: &mut fmt::Formatter) -> fmt::Result {
let csecs = self.time_remaining();
let secs = csecs / 100;
if secs <= 0 {
let min = -secs / 60;
write!(f, "-{:01}:{:02}", min, (-secs) - min * 60)
} else {
let min = secs / 60;
write!(f, "{:0... | fmt | identifier_name |
chario.rs | // Zinc, the bare metal stack for rust.
// Copyright 2014 Vladimir "farcaller" Pouzanov <farcaller@gmail.com>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.o... | () -> TestCharIO {
TestCharIO {
data: RefCell::new(TestCharIOData {
last_char: '\0',
putc_calls: 0,
}),
}
}
fn get_last_char(&self) -> char {
self.data.borrow().last_char
}
fn get_and_reset_putc_calls(&self) -> uint {
let current = self.data.... | new | identifier_name |
chario.rs | // Zinc, the bare metal stack for rust.
// Copyright 2014 Vladimir "farcaller" Pouzanov <farcaller@gmail.com>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.o... |
self.putc(i as char);
}
}
/// Outputs an integer.
fn puti(&self, i: u32) {
self.putint(i, 10);
}
/// Outputs an integer as a hex string.
fn puth(&self, i: u32) {
self.putint(i, 16);
}
}
#[cfg(test)]
pub mod test {
use core::cell::RefCell;
use drivers::chario::CharIO;
pub stru... | {
break;
} | conditional_block |
chario.rs | // Zinc, the bare metal stack for rust.
// Copyright 2014 Vladimir "farcaller" Pouzanov <farcaller@gmail.com>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.o... | pub fn new() -> TestCharIO {
TestCharIO {
data: RefCell::new(TestCharIOData {
last_char: '\0',
putc_calls: 0,
}),
}
}
fn get_last_char(&self) -> char {
self.data.borrow().last_char
}
fn get_and_reset_putc_calls(&self) -> uint {
let curren... | data.last_char = value;
}
}
impl TestCharIO { | random_line_split |
chario.rs | // Zinc, the bare metal stack for rust.
// Copyright 2014 Vladimir "farcaller" Pouzanov <farcaller@gmail.com>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.o... |
#[test]
fn puti_should_store_a_number_as_char() {
let io = TestCharIO::new();
io.puti(3);
assert!(io.get_last_char() == '3');
io.puti(9);
assert!(io.get_last_char() == '9');
io.puti(10);
assert!(io.get_last_char() == '0');
io.puti(11);
assert!(io.get_last_char() == '1');
}
... | {
let io = TestCharIO::new();
io.putc('a');
assert!(io.get_last_char() == 'a');
io.putc('z');
assert!(io.get_last_char() == 'z');
} | identifier_body |
dst-index.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 ... |
}
struct T;
impl Copy for T {}
impl Index<uint, Show +'static> for T {
fn index<'a>(&'a self, idx: &uint) -> &'a (Show +'static) {
static x: uint = 42;
&x
}
}
fn main() {
S[0];
//~^ ERROR cannot move out of dereference
//~^^ ERROR E0161
T[0];
//~^ ERROR cannot move out o... | {
"hello"
} | identifier_body |
dst-index.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 Copy for T {}
impl Index<uint, Show +'static> for T {
fn index<'a>(&'a self, idx: &uint) -> &'a (Show +'static) {
static x: uint = 42;
&x
}
}
fn main() {
S[0];
//~^ ERROR cannot move out of dereference
//~^^ ERROR E0161
T[0];
//~^ ERROR cannot move out of dereference
... |
struct T; | random_line_split |
dst-index.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 ... | <'a>(&'a self, _: &uint) -> &'a str {
"hello"
}
}
struct T;
impl Copy for T {}
impl Index<uint, Show +'static> for T {
fn index<'a>(&'a self, idx: &uint) -> &'a (Show +'static) {
static x: uint = 42;
&x
}
}
fn main() {
S[0];
//~^ ERROR cannot move out of dereference
/... | index | identifier_name |
status.rs | // Copyright 2017 LambdaStack All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law... | {
severity: String,
summary: String,
}
#[derive(RustcDecodable, RustcEncodable)]
pub struct CephStatusHealthDetail {
dummy: String,
}
#[derive(RustcDecodable, RustcEncodable)]
pub struct CephStatusMonMap {
epoch: u32,
fsid: String,
modified: String,
created: String,
mons: Vec<CephStat... | CephStatusHealthSummary | identifier_name |
status.rs | // Copyright 2017 LambdaStack All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law... | }
#[derive(RustcDecodable, RustcEncodable)]
pub struct CephStatusMonRank {
rank: u16,
name: String,
addr: String,
}
#[derive(RustcDecodable, RustcEncodable)]
pub struct CephStatusOSDMapH {
osdmap: CephStatusOSDMapL,
}
#[derive(RustcDecodable, RustcEncodable)]
pub struct CephStatusOSDMapL {
epoch:... | created: String,
mons: Vec<CephStatusMonRank>, | random_line_split |
mut_from_ref.rs | #![allow(unused)]
#![warn(clippy::mut_from_ref)]
struct Foo;
impl Foo {
fn this_wont_hurt_a_bit(&self) -> &mut Foo {
unimplemented!()
}
}
trait Ouch {
fn ouch(x: &Foo) -> &mut Foo;
}
impl Ouch for Foo {
fn ouch(x: &Foo) -> &mut Foo {
unimplemented!()
}
}
fn fail(x: &u32) -> &mut... | {
//TODO
} | identifier_body | |
mut_from_ref.rs | #![allow(unused)]
#![warn(clippy::mut_from_ref)]
struct Foo;
impl Foo {
fn this_wont_hurt_a_bit(&self) -> &mut Foo {
unimplemented!()
}
}
trait Ouch {
fn ouch(x: &Foo) -> &mut Foo;
} |
impl Ouch for Foo {
fn ouch(x: &Foo) -> &mut Foo {
unimplemented!()
}
}
fn fail(x: &u32) -> &mut u16 {
unimplemented!()
}
fn fail_lifetime<'a>(x: &'a u32, y: &mut u32) -> &'a mut u32 {
unimplemented!()
}
fn fail_double<'a, 'b>(x: &'a u32, y: &'a u32, z: &'b mut u32) -> &'a mut u32 {
unim... | random_line_split | |
mut_from_ref.rs | #![allow(unused)]
#![warn(clippy::mut_from_ref)]
struct | ;
impl Foo {
fn this_wont_hurt_a_bit(&self) -> &mut Foo {
unimplemented!()
}
}
trait Ouch {
fn ouch(x: &Foo) -> &mut Foo;
}
impl Ouch for Foo {
fn ouch(x: &Foo) -> &mut Foo {
unimplemented!()
}
}
fn fail(x: &u32) -> &mut u16 {
unimplemented!()
}
fn fail_lifetime<'a>(x: &'a u... | Foo | identifier_name |
issue-3563-3.rs | // run-pass
#![allow(unused_imports)]
#![allow(non_snake_case)]
// ASCII art shape renderer. Demonstrates traits, impls, operator overloading,
// non-copyable struct, unit testing. To run execute: rustc --test shapes.rs &&
//./shapes
// Rust's std library is tightly bound to the language itself so it is
// automati... |
return true;
}
fn test_ascii_art_ctor() {
let art = AsciiArt(3, 3, '*');
assert!(check_strs(&art.to_string(), "...\n...\n..."));
}
fn test_add_pt() {
let mut art = AsciiArt(3, 3, '*');
art.add_pt(0, 0);
art.add_pt(0, -10);
art.add_pt(1, 2);
assert!(check_strs(&art.to_string(), "*..\... | {
println!("Found:\n{}\nbut expected\n{}", actual, expected);
return false;
} | conditional_block |
issue-3563-3.rs | // run-pass
#![allow(unused_imports)]
#![allow(non_snake_case)]
// ASCII art shape renderer. Demonstrates traits, impls, operator overloading,
// non-copyable struct, unit testing. To run execute: rustc --test shapes.rs &&
//./shapes
// Rust's std library is tightly bound to the language itself so it is
// automati... | height: usize,
fill: char,
lines: Vec<Vec<char> >,
// This struct can be quite large so we'll disable copying: developers need
// to either pass these structs around via references or move them.
}
impl Drop for AsciiArt {
fn drop(&mut self) {}
}
// It's common to define a constructor sort of ... | random_line_split | |
issue-3563-3.rs | // run-pass
#![allow(unused_imports)]
#![allow(non_snake_case)]
// ASCII art shape renderer. Demonstrates traits, impls, operator overloading,
// non-copyable struct, unit testing. To run execute: rustc --test shapes.rs &&
//./shapes
// Rust's std library is tightly bound to the language itself so it is
// automati... | (&mut self, shape: Rect) {
// Add the top and bottom lines.
for x in shape.top_left.x..shape.top_left.x + shape.size.width {
self.add_pt(x, shape.top_left.y);
self.add_pt(x, shape.top_left.y + shape.size.height - 1);
}
// Add the left and right lines.
for... | add_rect | identifier_name |
room_key_request.rs | //! Types for the [`m.room_key_request`] event.
//!
//! [`m.room_key_request`]: https://spec.matrix.org/v1.2/client-server-api/#mroom_key_request
use ruma_macros::EventContent;
use ruma_serde::StringEnum;
use serde::{Deserialize, Serialize};
use crate::{DeviceId, EventEncryptionAlgorithm, PrivOwnedStr, RoomId, Transa... | } | random_line_split | |
room_key_request.rs | //! Types for the [`m.room_key_request`] event.
//!
//! [`m.room_key_request`]: https://spec.matrix.org/v1.2/client-server-api/#mroom_key_request
use ruma_macros::EventContent;
use ruma_serde::StringEnum;
use serde::{Deserialize, Serialize};
use crate::{DeviceId, EventEncryptionAlgorithm, PrivOwnedStr, RoomId, Transa... | (&self) -> &str {
self.as_ref()
}
}
/// Information about a requested key.
#[derive(Clone, Debug, Deserialize, Serialize)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct RequestedKeyInfo {
/// The encryption algorithm the requested key in this event is to be used wit... | as_str | identifier_name |
restoration_status.rs | // Copyright 2015-2017 Parity Technologies (UK) Ltd.
// This file is part of Parity. | // (at your option) any later version.
// Parity is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of t... |
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or | random_line_split |
restoration_status.rs | // Copyright 2015-2017 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any lat... | {
/// No restoration.
Inactive,
/// Ongoing restoration.
Ongoing {
/// Total number of state chunks.
state_chunks: u32,
/// Total number of block chunks.
block_chunks: u32,
/// Number of state chunks completed.
state_chunks_done: u32,
/// Number of block chunks completed.
block_chunks_done: u32,
}... | RestorationStatus | identifier_name |
motion.rs | use super::*;
impl Editor {
/// Convert an instruction to a motion (new coordinate). Returns None if the instructions given
/// either is invalid or has no movement.
///
/// A motion is a namespace (i.e. non mode-specific set of commands), which represents
/// movements. These are useful for comman... | (&mut self, Inst(n, cmd): Inst) -> Option<(usize, usize)> {
use super::Key::*;
match cmd.key {
Char('h') => Some(self.left(n.d())),
Char('l') => Some(self.right(n.d())),
Char('j') => Some(self.down(n.d())),
Char('k') => Some(self.up(n.d())),
Ch... | to_motion | identifier_name |
motion.rs | use super::*;
impl Editor {
/// Convert an instruction to a motion (new coordinate). Returns None if the instructions given
/// either is invalid or has no movement.
///
/// A motion is a namespace (i.e. non mode-specific set of commands), which represents
/// movements. These are useful for comman... |
},
Char(c) => {
self.status_bar.msg = format!("Motion not defined: '{}'", c);
self.redraw_status_bar();
None
},
_ => {
self.status_bar.msg = format!("Motion not defined");
None
},... | {
None
} | conditional_block |
motion.rs | /// either is invalid or has no movement.
///
/// A motion is a namespace (i.e. non mode-specific set of commands), which represents
/// movements. These are useful for commands which takes a motion as post-parameter, such as d.
/// d deletes the text given by the motion following. Other commands ca... | use super::*;
impl Editor {
/// Convert an instruction to a motion (new coordinate). Returns None if the instructions given | random_line_split | |
motion.rs | use super::*;
impl Editor {
/// Convert an instruction to a motion (new coordinate). Returns None if the instructions given
/// either is invalid or has no movement.
///
/// A motion is a namespace (i.e. non mode-specific set of commands), which represents
/// movements. These are useful for comman... | },
Char('f') => {
let ch = self.get_char();
if let Some(o) = self.previous_ocur(ch, n.d()) {
Some(to_signed_pos(o))
} else {
None
}
},
_ => None,
}
}
}
| {
use super::Key::*;
match cmd.key {
Char('h') => Some(self.left_unbounded(n.d())),
Char('l') => Some(self.right_unbounded(n.d())),
Char('j') => Some(self.down_unbounded(n.d())),
Char('k') => Some(self.up_unbounded(n.d())),
Char('g') => Some((0... | identifier_body |
lib.rs | /*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
//! # ConfigParser
//!
//! ConfigParser is a utility to parse hgrc-like config files.
//!
//! ## Features
//!
//! - Parse valid hgrc-like con... | //! %include path/to/another/hgrc.d
//! ```
//!
//! The include path is relative to the directory of the current config
//! file being parsed. If it's a directory, files with names ending
//! with `.rc` in it will be read.
//!
//! ### Unset a config
//!
//! Use `%unset` to unset a config:
//!
//! ```plain,ignore
//! [s... | random_line_split | |
llvm-asm-in-moved.rs | // run-pass
#![feature(llvm_asm)] | #[repr(C)]
struct NoisyDrop<'a>(&'a Cell<&'static str>);
impl<'a> Drop for NoisyDrop<'a> {
fn drop(&mut self) {
self.0.set("destroyed");
}
}
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
fn main() {
let status = Cell::new("alive");
{
let _y: Box<NoisyDrop>;
let x = Bo... | #![allow(deprecated)] // llvm_asm!
#![allow(dead_code)]
use std::cell::Cell;
| random_line_split |
llvm-asm-in-moved.rs | // run-pass
#![feature(llvm_asm)]
#![allow(deprecated)] // llvm_asm!
#![allow(dead_code)]
use std::cell::Cell;
#[repr(C)]
struct | <'a>(&'a Cell<&'static str>);
impl<'a> Drop for NoisyDrop<'a> {
fn drop(&mut self) {
self.0.set("destroyed");
}
}
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
fn main() {
let status = Cell::new("alive");
{
let _y: Box<NoisyDrop>;
let x = Box::new(NoisyDrop(&status));... | NoisyDrop | identifier_name |
llvm-asm-in-moved.rs | // run-pass
#![feature(llvm_asm)]
#![allow(deprecated)] // llvm_asm!
#![allow(dead_code)]
use std::cell::Cell;
#[repr(C)]
struct NoisyDrop<'a>(&'a Cell<&'static str>);
impl<'a> Drop for NoisyDrop<'a> {
fn drop(&mut self) |
}
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
fn main() {
let status = Cell::new("alive");
{
let _y: Box<NoisyDrop>;
let x = Box::new(NoisyDrop(&status));
unsafe {
llvm_asm!("mov $1, $0" : "=r"(_y) : "r"(x));
}
assert_eq!(status.get(), "alive");... | {
self.0.set("destroyed");
} | identifier_body |
basic_shape.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/. */
//! CSS handling for the [`basic-shape`](https://drafts.csswg.org/css-shapes/#typedef-basic-shape)
//! types that... | #[allow(missing_docs)]
#[derive(
Animate, Clone, Copy, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss,
)]
pub enum GeometryBox {
FillBox,
StrokeBox,
ViewBox,
ShapeBox(ShapeBox),
}
/// A float area shape, for `shape-outside`.
pub type FloatAreaShape<BasicShape, Image> = S... | pub type ClippingShape<BasicShape, Url> = ShapeSource<BasicShape, GeometryBox, Url>;
/// <https://drafts.fxtf.org/css-masking-1/#typedef-geometry-box> | random_line_split |
basic_shape.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/. */
//! CSS handling for the [`basic-shape`](https://drafts.csswg.org/css-shapes/#typedef-basic-shape)
//! types that... | {
/// The filling rule for the svg path.
#[css(skip_if = "fill_is_default")]
#[animation(constant)]
pub fill: FillRule,
/// The svg path data.
pub path: SVGPathData,
}
// FIXME(nox): Implement ComputeSquaredDistance for T types and stop
// using PartialEq here, this will let us derive this imp... | Path | identifier_name |
basic_shape.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/. */
//! CSS handling for the [`basic-shape`](https://drafts.csswg.org/css-shapes/#typedef-basic-shape)
//! types that... | ,
(&ShapeSource::Path(ref this), &ShapeSource::Path(ref other))
if this.fill == other.fill =>
{
this.path.compute_squared_distance(&other.path)
},
_ => Err(()),
}
}
}
impl<B, T, U> ToAnimatedZero for ShapeSource<B, T, U> {
... | {
this.compute_squared_distance(other)
} | conditional_block |
oracle.rs | use aes;
use rand;
pub struct Oracle {
key: [u8; 16],
iv: [u8; 16],
}
impl Oracle {
pub fn new() -> Oracle {
Oracle {
key: random_block(),
iv: random_block()
}
}
#[cfg(test)]
pub fn controlled(key : &[u8; 16], iv: &[u8; 16]) -> Oracle {
Oracle {... |
use super::contains;
#[test]
fn contains_pass() {
let container = vec![0,1,2,3,4];
let containee = vec![2,3];
assert_eq!(contains(&container[..], &containee[..]), true);
}
#[test]
fn contains_fail() {
let container = vec![0,1,2,3,4];
let containee = ve... | {
let key = [0x79, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x20, 0x73, 0x75, 0x62,
0x6d, 0x61, 0x72, 0x69, 0x6e, 0x65]; //"yellow submarine"
let iv = [0x74, 0x68, 0x65, 0x20, 0x31, 0x73, 0x74, 0x20, 0x31, 0x36,
0x20, 0x62, 0x79, 0x74, 0x65, 0x73]; //"the 1st 16 bytes"
... | identifier_body |
oracle.rs | use aes;
use rand;
pub struct Oracle {
key: [u8; 16],
iv: [u8; 16],
}
impl Oracle {
pub fn new() -> Oracle {
Oracle {
key: random_block(),
iv: random_block()
}
}
#[cfg(test)]
pub fn controlled(key : &[u8; 16], iv: &[u8; 16]) -> Oracle {
Oracle {... | 0xeb, 0xac, 0x3b, 0x47, 0x7a, 0xd1, 0x3d, 0x92, 0x2b,
0x40, 0x8a, 0x39, 0xd0, 0x34, 0xf9, 0x9e, 0x5b, 0x18,
0x3a, 0xbe, 0x51, 0x64, 0x6f, 0x21, 0x90, 0xc1, 0x64,
0x6b, 0xbe, 0x8a, 0x16, 0x2b, 0x41, 0x1c, 0x35... | let output = oracle.encrypt("");
let expected = vec![0x5f, 0x42, 0xc3, 0xdd, 0x32, 0xfe, 0x04, 0x86, 0x21,
0xc0, 0xea, 0xc1, 0x96, 0xbd, 0x01, 0xe4, 0x79, 0xdb,
0x1c, 0x4d, 0xd9, 0x78, 0x9a, 0x41, 0xac, 0xfd, 0x0a, | random_line_split |
oracle.rs | use aes;
use rand;
pub struct Oracle {
key: [u8; 16],
iv: [u8; 16],
}
impl Oracle {
pub fn new() -> Oracle {
Oracle {
key: random_block(),
iv: random_block()
}
}
#[cfg(test)]
pub fn controlled(key : &[u8; 16], iv: &[u8; 16]) -> Oracle {
Oracle {... | () -> [u8; 16] {
use rand::Rng;
let mut rng = rand::thread_rng();
let mut block = [0u8; 16];
for el in block.iter_mut() {
*el = rng.gen::<u8>();
}
block
}
fn contains(container: &[u8], containee: &[u8]) -> bool {
for idx in 0..(container.len()-containee.len()) {
if containe... | random_block | identifier_name |
oracle.rs | use aes;
use rand;
pub struct Oracle {
key: [u8; 16],
iv: [u8; 16],
}
impl Oracle {
pub fn new() -> Oracle {
Oracle {
key: random_block(),
iv: random_block()
}
}
#[cfg(test)]
pub fn controlled(key : &[u8; 16], iv: &[u8; 16]) -> Oracle {
Oracle {... |
else {
false
}
}
}
fn random_block() -> [u8; 16] {
use rand::Rng;
let mut rng = rand::thread_rng();
let mut block = [0u8; 16];
for el in block.iter_mut() {
*el = rng.gen::<u8>();
}
block
}
fn contains(container: &[u8], containee: &[u8]) -> bool {
fo... | {
contains(&decoded, "user=admin".as_bytes())
} | conditional_block |
rule_list.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/. */
//! A list of CSS rules.
#[cfg(feature = "gecko")]
use malloc_size_of::{MallocShallowSizeOf, MallocSizeOfOps};
us... |
}
}
// Step 5, 6
self.0.remove(index);
Ok(())
}
}
/// A trait to implement helpers for `Arc<Locked<CssRules>>`.
pub trait CssRulesHelpers {
/// <https://drafts.csswg.org/cssom/#insert-a-css-rule>
///
/// Written in this funky way because parsing an @import ... | {
return Err(RulesMutateError::InvalidState);
} | conditional_block |
rule_list.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/. */
//! A list of CSS rules.
#[cfg(feature = "gecko")]
use malloc_size_of::{MallocShallowSizeOf, MallocSizeOfOps};
us... | (&self) -> bool {
self.0.is_empty()
}
}
impl DeepCloneWithLock for CssRules {
fn deep_clone_with_lock(
&self,
lock: &SharedRwLock,
guard: &SharedRwLockReadGuard,
params: &DeepCloneParams,
) -> Self {
CssRules(self.0.iter().map(|x| {
x.deep_clone_w... | is_empty | identifier_name |
rule_list.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/. */
//! A list of CSS rules.
#[cfg(feature = "gecko")]
use malloc_size_of::{MallocShallowSizeOf, MallocSizeOfOps};
us... | // Step 3, 4
// XXXManishearth should we also store the namespace map?
let (new_rule, new_state) =
CssRule::parse(
&rule,
parent_stylesheet_contents,
lock,
state,
loader
)?;
{
... | {
let state = {
let read_guard = lock.read();
let rules = self.read_with(&read_guard);
// Step 1, 2
if index > rules.0.len() {
return Err(RulesMutateError::IndexSize);
}
// Computes the parser state at the given index
... | identifier_body |
rule_list.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/. */
//! A list of CSS rules.
#[cfg(feature = "gecko")]
use malloc_size_of::{MallocShallowSizeOf, MallocSizeOfOps};
us... | pub fn size_of(&self, guard: &SharedRwLockReadGuard, ops: &mut MallocSizeOfOps) -> usize {
let mut n = self.0.shallow_size_of(ops);
for rule in self.0.iter() {
n += rule.size_of(guard, ops);
}
n
}
/// Trivially construct a new set of CSS rules.
pub fn new(rul... | impl CssRules {
/// Measure heap usage.
#[cfg(feature = "gecko")] | random_line_split |
digitalocean.rs | use super::command;
use super::chain;
fn get_subdomain_from_name(name: &str) -> &str {
// For subdomains, we only take the first element when split by ".", this allows
// us to create naked domain names or use the same subdomain across domains.
let components: Vec<&str> = name.split(".").collect();
if ... | (name: &str) {
// By default, always attempt to add a new key with [name] mapping to ~/.ssh/id_rsa.pub
let create_key_str = format!("doctl compute ssh-key create {} --public-key=\"$(cat ~/.ssh/id_rsa.pub)\"", name);
println!("Running command:\n\t\t{}", create_key_str);
// Create the actual droplet
l... | create_sshkey | identifier_name |
digitalocean.rs | use super::command;
use super::chain;
fn get_subdomain_from_name(name: &str) -> &str {
// For subdomains, we only take the first element when split by ".", this allows
// us to create naked domain names or use the same subdomain across domains.
let components: Vec<&str> = name.split(".").collect();
if ... |
}
pub fn create_droplet_by_name(name: &str, region: Option<&str>, size: Option<&str>, domain: Option<&str>,
enable_backups: Option<&str>) {
let ssh_key_mapping_func = |res: &command::Result, cmd_str: String| -> String {
let ids : Vec<&str> = res.stdout.lines().collect();
... | {
&"@"
} | conditional_block |
digitalocean.rs | use super::command;
use super::chain;
fn get_subdomain_from_name(name: &str) -> &str {
// For subdomains, we only take the first element when split by ".", this allows
// us to create naked domain names or use the same subdomain across domains.
let components: Vec<&str> = name.split(".").collect();
if ... | let list_records_cmd = format!("doctl compute domain records list {} --format Name,ID --no-header", domain_name);
let delete_record_cmd = format!("doctl compute domain records delete -f {} %record_id%", domain_name);
// TODO: check the result heh
let _ = chain::CommandChain::new()
.cmd_nonfatal(... | let delete_droplet_cmd = format!("doctl compute droplet delete -f {}", name); | random_line_split |
digitalocean.rs | use super::command;
use super::chain;
fn get_subdomain_from_name(name: &str) -> &str |
pub fn create_droplet_by_name(name: &str, region: Option<&str>, size: Option<&str>, domain: Option<&str>,
enable_backups: Option<&str>) {
let ssh_key_mapping_func = |res: &command::Result, cmd_str: String| -> String {
let ids : Vec<&str> = res.stdout.lines().collect();
... | {
// For subdomains, we only take the first element when split by ".", this allows
// us to create naked domain names or use the same subdomain across domains.
let components: Vec<&str> = name.split(".").collect();
if components.len() > 2 {
// If first throws an error after we've checked length,... | identifier_body |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.