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 |
|---|---|---|---|---|
constant_offsets.rs | // SPDX-License-Identifier: MIT
// Copyright wtfsckgh@gmail.com
// Copyright iced contributors
use core::hash::{Hash, Hasher};
use pyo3::class::basic::CompareOp;
use pyo3::prelude::*;
use pyo3::PyObjectProtocol;
use std::collections::hash_map::DefaultHasher;
/// Contains the offsets of the displacement and immediate.... |
/// int: (``u32``) Size in bytes of the displacement, or 0 if there's no displacement
#[getter]
fn displacement_size(&self) -> u32 {
self.offsets.displacement_size() as u32
}
/// int: (``u32``) The offset of the first immediate, if any.
///
/// This field can be invalid even if the operand has an immediate ... | {
self.offsets.displacement_offset() as u32
} | identifier_body |
constant_offsets.rs | // SPDX-License-Identifier: MIT
// Copyright wtfsckgh@gmail.com
// Copyright iced contributors
use core::hash::{Hash, Hasher};
use pyo3::class::basic::CompareOp;
use pyo3::prelude::*;
use pyo3::PyObjectProtocol;
use std::collections::hash_map::DefaultHasher;
/// Contains the offsets of the displacement and immediate.... | /// bool: ``True`` if :class:`ConstantOffsets.immediate_offset2` and :class:`ConstantOffsets.immediate_size2` are valid
#[getter]
fn has_immediate2(&self) -> bool {
self.offsets.has_immediate2()
}
/// Returns a copy of this instance.
///
/// Returns:
/// ConstantOffsets: A copy of this instance
///
///... | #[getter]
fn has_immediate(&self) -> bool {
self.offsets.has_immediate()
}
| random_line_split |
visitor.rs | // Copyright 2016 Pierre Talbot (IRCAM)
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to... |
fn visit_external_non_terminal_symbol(&mut self, _this: usize, _rule: &syn::Path) -> R { R::default() }
fn visit_atom(&mut self, _this: usize) -> R { R::default() }
fn visit_any_single_char(&mut self, this: usize) -> R {
self.visit_atom(this)
}
fn visit_character_class(&mut self, this: usize, _char_cla... | { R::default() } | identifier_body |
visitor.rs | // Copyright 2016 Pierre Talbot (IRCAM)
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to... |
ZeroOrOne(child) => {
visitor.visit_optional(this, child)
}
NotPredicate(child) => {
visitor.visit_not_predicate(this, child)
}
AndPredicate(child) => {
visitor.visit_and_predicate(this, child)
}
CharacterClass(char_class) => {
visitor.visit_character_class(this, cha... | {
visitor.visit_one_or_more(this, child)
} | conditional_block |
visitor.rs | // Copyright 2016 Pierre Talbot (IRCAM)
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to... | (&mut self, this: usize, child: usize) -> R {
self.visit_repeat(this, child)
}
fn visit_one_or_more(&mut self, this: usize, child: usize) -> R {
self.visit_repeat(this, child)
}
fn visit_optional(&mut self, _this: usize, child: usize) -> R {
self.visit_expr(child)
}
fn visit_syntactic_predica... | visit_zero_or_more | identifier_name |
visitor.rs | // Copyright 2016 Pierre Talbot (IRCAM)
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to... | fn visit_expr(&mut self, this: usize) -> R {
walk_expr(self, this)
}
fn visit_str_literal(&mut self, _this: usize, _lit: String) -> R { R::default() }
fn visit_non_terminal_symbol(&mut self, _this: usize, _rule: &Ident) -> R { R::default() }
fn visit_external_non_terminal_symbol(&mut self, _this: usize, ... | random_line_split | |
eulers_sum_of_powers_conjecture.rs | // http://rosettacode.org/wiki/Euler's_sum_of_powers_conjecture
const MAX_N: u64 = 250;
fn | () -> (usize, usize, usize, usize, usize) {
let pow5: Vec<u64> = (0..MAX_N).map(|i| i.pow(5)).collect();
let pow5_to_n = |pow| pow5.binary_search(&pow);
for x0 in 1..MAX_N as usize {
for x1 in 1..x0 {
for x2 in 1..x1 {
for x3 in 1..x2 {
let pow_sum = ... | eulers_sum_of_powers | identifier_name |
eulers_sum_of_powers_conjecture.rs | // http://rosettacode.org/wiki/Euler's_sum_of_powers_conjecture
const MAX_N: u64 = 250;
fn eulers_sum_of_powers() -> (usize, usize, usize, usize, usize) |
fn main() {
let (x0, x1, x2, x3, y) = eulers_sum_of_powers();
println!("{}^5 + {}^5 + {}^5 + {}^5 == {}^5", x0, x1, x2, x3, y)
}
| {
let pow5: Vec<u64> = (0..MAX_N).map(|i| i.pow(5)).collect();
let pow5_to_n = |pow| pow5.binary_search(&pow);
for x0 in 1..MAX_N as usize {
for x1 in 1..x0 {
for x2 in 1..x1 {
for x3 in 1..x2 {
let pow_sum = pow5[x0] + pow5[x1] + pow5[x2] + pow5[x3];... | identifier_body |
eulers_sum_of_powers_conjecture.rs | // http://rosettacode.org/wiki/Euler's_sum_of_powers_conjecture
const MAX_N: u64 = 250;
fn eulers_sum_of_powers() -> (usize, usize, usize, usize, usize) {
let pow5: Vec<u64> = (0..MAX_N).map(|i| i.pow(5)).collect();
let pow5_to_n = |pow| pow5.binary_search(&pow);
for x0 in 1..MAX_N as usize {
for ... | } | println!("{}^5 + {}^5 + {}^5 + {}^5 == {}^5", x0, x1, x2, x3, y) | random_line_split |
eulers_sum_of_powers_conjecture.rs | // http://rosettacode.org/wiki/Euler's_sum_of_powers_conjecture
const MAX_N: u64 = 250;
fn eulers_sum_of_powers() -> (usize, usize, usize, usize, usize) {
let pow5: Vec<u64> = (0..MAX_N).map(|i| i.pow(5)).collect();
let pow5_to_n = |pow| pow5.binary_search(&pow);
for x0 in 1..MAX_N as usize {
for ... |
}
}
}
}
panic!();
}
fn main() {
let (x0, x1, x2, x3, y) = eulers_sum_of_powers();
println!("{}^5 + {}^5 + {}^5 + {}^5 == {}^5", x0, x1, x2, x3, y)
}
| {
return (x0, x1, x2, x3, n)
} | conditional_block |
stylesheet.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 {Namespace, Prefix};
use context::QuirksMode;
use cssparser::{Parser, ParserInput, RuleListParser};
use error_... | <R>(
existing: &Stylesheet,
css: &str,
url_data: UrlExtraData,
stylesheet_loader: Option<&StylesheetLoader>,
error_reporter: &R,
line_number_offset: u32,
) where
R: ParseErrorReporter,
{
let namespaces = RwLock::new(Namespaces::default());
... | update_from_str | identifier_name |
stylesheet.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 {Namespace, Prefix};
use context::QuirksMode;
use cssparser::{Parser, ParserInput, RuleListParser};
use error_... | }
}
)+
}
}
/// A trait to represent a given stylesheet in a document.
pub trait StylesheetInDocument {
/// Get the stylesheet origin.
fn origin(&self, guard: &SharedRwLockReadGuard) -> Origin;
/// Get the stylesheet quirks mode.
fn quirks_mode(&self, guard: &Sha... | random_line_split | |
stylesheet.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 {Namespace, Prefix};
use context::QuirksMode;
use cssparser::{Parser, ParserInput, RuleListParser};
use error_... |
}
/// The structure servo uses to represent a stylesheet.
#[derive(Debug)]
pub struct Stylesheet {
/// The contents of this stylesheet.
pub contents: StylesheetContents,
/// The lock used for objects inside this stylesheet
pub shared_lock: SharedRwLock,
/// List of media associated with the Styles... | {
// Make a deep clone of the rules, using the new lock.
let rules = self.rules
.read_with(guard)
.deep_clone_with_lock(lock, guard, params);
Self {
rules: Arc::new(lock.wrap(rules)),
quirks_mode: self.quirks_mode,
origin: self.origin,... | identifier_body |
main.rs | use docopt::Docopt;
use eyre::bail;
use serde::Deserialize;
use std::fs::File;
use std::io::{self, BufRead, BufReader};
use std::path::Path;
use std::process;
const USAGE: &str = "
Print or check BLAKE2 (512-bit) checksums.
With no FILE, or when FILE is -, read standard input.
Usage:
b2sum [options] []...
b2sum (... |
}
| {
let expected = "7ea59e7a000ec003846b6607dfd5f9217b681dc1a81b0789b464c3995105d93083f7f0a86fca01a1bed27e9f9303ae58d01746e3b20443480bea56198e65bfc5";
assert_eq!(expected, hash_reader(64, "hi\n".as_bytes()).unwrap());
} | identifier_body |
main.rs | use docopt::Docopt;
use eyre::bail;
use serde::Deserialize;
use std::fs::File;
use std::io::{self, BufRead, BufReader};
use std::path::Path;
use std::process;
const USAGE: &str = "
Print or check BLAKE2 (512-bit) checksums.
With no FILE, or when FILE is -, read standard input.
Usage:
b2sum [options] []...
b2sum (... | Ok(errors)
}
fn check_args(args: Args) -> eyre::Result<i32> {
let filename = args.arg_filename[0].as_str();
let errors = if filename == "-" {
let stdin = io::stdin();
check_input(&args, filename, stdin.lock())?
} else {
let file = File::open(filename)?;
let reader = BufR... | println!("FAILED");
}
}
}
| random_line_split |
main.rs | use docopt::Docopt;
use eyre::bail;
use serde::Deserialize;
use std::fs::File;
use std::io::{self, BufRead, BufReader};
use std::path::Path;
use std::process;
const USAGE: &str = "
Print or check BLAKE2 (512-bit) checksums.
With no FILE, or when FILE is -, read standard input.
Usage:
b2sum [options] []...
b2sum (... | (args: Args) -> eyre::Result<i32> {
let filename = args.arg_filename[0].as_str();
let errors = if filename == "-" {
let stdin = io::stdin();
check_input(&args, filename, stdin.lock())?
} else {
let file = File::open(filename)?;
let reader = BufReader::new(file);
check... | check_args | identifier_name |
main.rs | use docopt::Docopt;
use eyre::bail;
use serde::Deserialize;
use std::fs::File;
use std::io::{self, BufRead, BufReader};
use std::path::Path;
use std::process;
const USAGE: &str = "
Print or check BLAKE2 (512-bit) checksums.
With no FILE, or when FILE is -, read standard input.
Usage:
b2sum [options] []...
b2sum (... | ;
process::exit(result)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn split_check_line_with_valid_line() {
let line = "c0ae24f806df19d850565b234bc37afd5035e7536388290db9413c98578394313f38b093143ecfbc208425d54b9bfef0d9917a9e93910f7914a97e73fea23534 test";
let (hash, filename) = s... | { hash_args(args)? } | conditional_block |
simple-struct.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
// debugger:print padding_at_end
// check:$6 = {x = -10014, y = 10015}
struct NoPadding16 {
x: u16,
y: i16
}
struct NoPadding32 {
x: i32,
y: f32,
z: u32
}
struct NoPadding64 {
x: f64,
y: i64,
z: u64
}
struct NoPadding163264 {
a: i16,
b: u16,
c: i32,
d: u64
}
struct... | // debugger:print internal_padding
// check:$5 = {x = 10012, y = -10013} | random_line_split |
simple-struct.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | {
x: i64,
y: u16
}
fn main() {
let no_padding16 = NoPadding16 { x: 10000, y: -10001 };
let no_padding32 = NoPadding32 { x: -10002, y: -10003.5, z: 10004 };
let no_padding64 = NoPadding64 { x: -10005.5, y: 10006, z: 10007 };
let no_padding163264 = NoPadding163264 { a: -10008, b: 10009, c: 10010... | PaddingAtEnd | identifier_name |
lib.rs | // The MIT License (MIT)
//
// Copyright (c) 2016 Marvin Böcker
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, c... | ) {
use chrono::Timelike;
use chrono::UTC;
use chrono::duration::Duration;
use meta::Meta;
use certificate::Certificate;
use validator::Validator;
use root_validator::RootValidator;
use trust_validator::TrustValidator;
use revoker::NoRevoker;
use fingerprint::Fingerprint;
//... | est_readme_example( | identifier_name |
lib.rs | // The MIT License (MIT)
//
// Copyright (c) 2016 Marvin Böcker
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, c... | .with_nanosecond(0)
.unwrap();
let mut cert = Certificate::generate_random(meta, expires);
// sign certificate with master key
cert.sign_with_master(&msk);
// we can use a RootValidator, which analyzes the trust chain.
// in this case, the top-most certificate must be signed with the... |
use chrono::Timelike;
use chrono::UTC;
use chrono::duration::Duration;
use meta::Meta;
use certificate::Certificate;
use validator::Validator;
use root_validator::RootValidator;
use trust_validator::TrustValidator;
use revoker::NoRevoker;
use fingerprint::Fingerprint;
// cr... | identifier_body |
lib.rs | // The MIT License (MIT)
//
// Copyright (c) 2016 Marvin Böcker
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, c... | //! This crate is a simple digital signature crate and can be used to verify data integrity by
//! using public-key cryptography. It uses the "super-fast, super-secure" elliptic curve and
//! digital signature algorithm [Ed25519](https://ed25519.cr.yp.to/).
//!
//! It provides the struct `Certificate`, which holds the ... | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
| random_line_split |
aliased.rs | use expression::{Expression, NonAggregate, SelectableExpression};
use query_builder::*;
use query_source::*;
#[derive(Debug, Clone, Copy)] | expr: Expr,
alias: &'a str,
}
impl<'a, Expr> Aliased<'a, Expr> {
pub fn new(expr: Expr, alias: &'a str) -> Self {
Aliased {
expr: expr,
alias: alias,
}
}
}
pub struct FromEverywhere;
impl<'a, T> Expression for Aliased<'a, T> where T: Expression {
type SqlTy... | pub struct Aliased<'a, Expr> { | random_line_split |
aliased.rs | use expression::{Expression, NonAggregate, SelectableExpression};
use query_builder::*;
use query_source::*;
#[derive(Debug, Clone, Copy)]
pub struct Aliased<'a, Expr> {
expr: Expr,
alias: &'a str,
}
impl<'a, Expr> Aliased<'a, Expr> {
pub fn new(expr: Expr, alias: &'a str) -> Self {
Aliased {
... | (&self, out: &mut QueryBuilder) -> BuildQueryResult {
out.push_identifier(&self.alias)
}
}
// FIXME This is incorrect, should only be selectable from WithQuerySource
impl<'a, T, QS> SelectableExpression<QS> for Aliased<'a, T> where
Aliased<'a, T>: Expression,
{
}
impl<'a, T: Expression> QuerySource fo... | to_sql | identifier_name |
font_context.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 font::{Font, FontGroup};
use font::SpecifiedFontStyle;
use platform::font_context::FontContextHandle;
use styl... | (&self, template: Arc<FontTemplateData>,
descriptor: FontTemplateDescriptor, pt_size: f64) -> Font {
let handle: FontHandle = FontHandleMethods::new_from_template(&self.platform_handle, template, Some(pt_size)).unwrap();
let metrics = handle.get_metrics();
Font {
... | create_layout_font | identifier_name |
font_context.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 font::{Font, FontGroup};
use font::SpecifiedFontStyle;
use platform::font_context::FontContextHandle;
use styl... |
}
let render_font = Rc::new(RefCell::new(create_scaled_font(backend, template, pt_size)));
self.render_font_cache.push(RenderFontCacheEntry{
font: render_font.clone(),
pt_size: pt_size,
identifier: template.identifier.clone(),
});
render_font... | {
return cached_font.font.clone();
} | conditional_block |
font_context.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 font::{Font, FontGroup};
use font::SpecifiedFontStyle;
use platform::font_context::FontContextHandle;
use styl... |
/// Create a font for use in layout calculations.
fn create_layout_font(&self, template: Arc<FontTemplateData>,
descriptor: FontTemplateDescriptor, pt_size: f64) -> Font {
let handle: FontHandle = FontHandleMethods::new_from_template(&self.platform_handle, template, Some(p... | {
let handle = FontContextHandle::new();
FontContext {
platform_handle: handle,
font_cache_task: font_cache_task,
layout_font_cache: vec!(),
render_font_cache: vec!(),
}
} | identifier_body |
font_context.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 font::{Font, FontGroup};
use font::SpecifiedFontStyle;
use platform::font_context::FontContextHandle;
use styl... | fn create_scaled_font(backend: BackendType, template: &Arc<FontTemplateData>, pt_size: f64) -> ScaledFont {
let cgfont = template.ctfont.copy_to_CGFont();
ScaledFont::new(backend, &cgfont, pt_size as AzFloat)
}
/// A cached azure font (per render task) that
/// can be shared by multiple text runs.
struct Rende... | #[cfg(target_os="macos")] | random_line_split |
inline.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 ... | llfn,
empty_substs,
impl_item.id,
&[]);
// See linkage comments on items.
if ccx.sess().opts.cg.codegen_units == 1 {
SetLinkage(llfn, Intern... | trans_fn(ccx,
&sig.decl,
body, | random_line_split |
inline.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 ... | {
get_local_instance(ccx, fn_id).unwrap_or(fn_id)
} | identifier_body | |
inline.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 ... | (ccx: &CrateContext, fn_id: ast::DefId)
-> Option<ast::DefId> {
debug!("instantiate_inline({:?})", fn_id);
let _icx = push_ctxt("instantiate_inline");
match ccx.external().borrow().get(&fn_id) {
Some(&Some(node_id)) => {
// Already inline
debug!("instantiate_inline({}): ... | instantiate_inline | identifier_name |
attribute-with-error.rs | // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT. | // except according to those terms.
// aux-build:attribute-with-error.rs
#![feature(custom_inner_attributes)]
extern crate attribute_with_error;
use attribute_with_error::foo;
#[foo]
fn test1() {
let a: i32 = "foo";
//~^ ERROR: mismatched types
let b: i32 = "f'oo";
//~^ ERROR: mismatched types
}
f... | //
// 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 | random_line_split |
attribute-with-error.rs | // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
fn test2() {
#![foo]
// FIXME: should have a type error here and assert it works but it doesn't
}
trait A {
// FIXME: should have a #[foo] attribute here and assert that it works
fn foo(&self) {
let a: i32 = "foo";
//~^ ERROR: mismatched types
}
}
struct B;
impl A for B {
#... | {
let a: i32 = "foo";
//~^ ERROR: mismatched types
let b: i32 = "f'oo";
//~^ ERROR: mismatched types
} | identifier_body |
attribute-with-error.rs | // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | (&self) {
let a: i32 = "foo";
//~^ ERROR: mismatched types
}
}
struct B;
impl A for B {
#[foo]
fn foo(&self) {
let a: i32 = "foo";
//~^ ERROR: mismatched types
}
}
#[foo]
fn main() {
}
| foo | identifier_name |
shootout-spectralnorm.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 {
args
};
let N = uint::from_str(args[1]).get();
let mut u = vec::from_elem(N, 1.0);
let mut v = vec::from_elem(N, 0.0);
let mut i = 0u;
while i < 10u {
eval_AtA_times_u(u, v);
eval_AtA_times_u(v, u);
i += 1u;
}
let mut vBv = 0.0;
let mut vv =... | {
~[~"", ~"1000"]
} | conditional_block |
shootout-spectralnorm.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 mut v = vec::from_elem(N, 0.0);
let mut i = 0u;
while i < 10u {
eval_AtA_times_u(u, v);
eval_AtA_times_u(v, u);
i += 1u;
}
let mut vBv = 0.0;
let mut vv = 0.0;
let mut i = 0u;
while i < N {
vBv += u[i] * v[i];
vv += v[i] * v[i];
i += 1... |
let N = uint::from_str(args[1]).get();
let mut u = vec::from_elem(N, 1.0); | random_line_split |
shootout-spectralnorm.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 ... | (u: &const [float], Au: &mut [float]) {
let N = vec::len(u);
let mut i = 0u;
while i < N {
Au[i] = 0.0;
let mut j = 0u;
while j < N {
Au[i] += eval_A(i, j) * u[j];
j += 1u;
}
i += 1u;
}
}
fn eval_At_times_u(u: &const [float], Au: &mut [flo... | eval_A_times_u | identifier_name |
shootout-spectralnorm.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
fn eval_At_times_u(u: &const [float], Au: &mut [float]) {
let N = vec::len(u);
let mut i = 0u;
while i < N {
Au[i] = 0.0;
let mut j = 0u;
while j < N {
Au[i] += eval_A(j, i) * u[j];
j += 1u;
}
i += 1u;
}
}
fn eval_AtA_times_u(u: &const [... | {
let N = vec::len(u);
let mut i = 0u;
while i < N {
Au[i] = 0.0;
let mut j = 0u;
while j < N {
Au[i] += eval_A(i, j) * u[j];
j += 1u;
}
i += 1u;
}
} | identifier_body |
context.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | (regs: &mut Registers, fptr: *c_void, arg: *c_void,
sp: *mut uint, _stack_base: *uint) {
let sp = align_down(sp);
// sp of mips o32 is 8-byte aligned
let sp = mut_offset(sp, -2);
// The final return address. 0 indicates the bottom of the stack
unsafe { *sp = 0; }
regs[... | initialize_call_frame | identifier_name |
context.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | {
use std::sys::size_of;
(ptr as int + count * (size_of::<T>() as int)) as *mut T
} | identifier_body | |
context.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT. | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use option::*;
use ... | // | random_line_split |
test_stmt.rs | #![allow(clippy::non_ascii_literal)]
#[macro_use]
mod macros;
use proc_macro2::{Delimiter, Group, Ident, Span, TokenStream, TokenTree};
use std::iter::FromIterator;
use syn::Stmt;
#[test]
fn test_raw_operator() {
let stmt = syn::parse_str::<Stmt>("let _ = &raw const x;").unwrap();
snapshot!(stmt, @r###"
... | output: Default,
},
block: Block,
})
"###);
}
| {
// <Ø async fn f() {} Ø>
let tokens = TokenStream::from_iter(vec![TokenTree::Group(Group::new(
Delimiter::None,
TokenStream::from_iter(vec![
TokenTree::Ident(Ident::new("async", Span::call_site())),
TokenTree::Ident(Ident::new("fn", Span::call_site())),
Toke... | identifier_body |
test_stmt.rs | #![allow(clippy::non_ascii_literal)]
#[macro_use]
mod macros;
use proc_macro2::{Delimiter, Group, Ident, Span, TokenStream, TokenTree};
use std::iter::FromIterator;
use syn::Stmt;
#[test]
fn test_raw_operator() {
let stmt = syn::parse_str::<Stmt>("let _ = &raw const x;").unwrap();
snapshot!(stmt, @r###"
... | Local(Local {
pat: Pat::Wild,
init: Some(Expr::Reference {
expr: Expr::Path {
path: Path {
segments: [
PathSegment {
ident: "raw",
arguments: None,
... | let stmt = syn::parse_str::<Stmt>("let _ = &raw;").unwrap();
snapshot!(stmt, @r###" | random_line_split |
test_stmt.rs | #![allow(clippy::non_ascii_literal)]
#[macro_use]
mod macros;
use proc_macro2::{Delimiter, Group, Ident, Span, TokenStream, TokenTree};
use std::iter::FromIterator;
use syn::Stmt;
#[test]
fn test_raw_operator() {
let stmt = syn::parse_str::<Stmt>("let _ = &raw const x;").unwrap();
snapshot!(stmt, @r###"
... | () {
let stmt = syn::parse_str::<Stmt>("let _ = &raw;").unwrap();
snapshot!(stmt, @r###"
Local(Local {
pat: Pat::Wild,
init: Some(Expr::Reference {
expr: Expr::Path {
path: Path {
segments: [
PathSegment {
... | test_raw_variable | identifier_name |
no_0014_longest_common_prefix.rs | struct Solution;
impl Solution {
pub fn longest_common_prefix(strs: Vec<String>) -> String {
match strs.len() {
0 => return String::new(),
1 => return strs[0].clone(),
_ => (),
};
let mut buf = String::new();
for (i, c) in strs[0].as_bytes().iter... | }
}
#[cfg(test)]
mod test {
use super::*;
#[test]
fn test_longest_common_prefix() {
let strs = vec!["flower", "flow", "flight"]
.iter()
.map(|x| x.to_string())
.collect();
assert_eq!(Solution::longest_common_prefix(strs), "fl".to_owned());
let ... | buf.push(*c as char);
}
buf | random_line_split |
no_0014_longest_common_prefix.rs | struct Solution;
impl Solution {
pub fn longest_common_prefix(strs: Vec<String>) -> String {
match strs.len() {
0 => return String::new(),
1 => return strs[0].clone(),
_ => (),
};
let mut buf = String::new();
for (i, c) in strs[0].as_bytes().iter... |
}
buf.push(*c as char);
}
buf
}
}
#[cfg(test)]
mod test {
use super::*;
#[test]
fn test_longest_common_prefix() {
let strs = vec!["flower", "flow", "flight"]
.iter()
.map(|x| x.to_string())
.collect();
assert_eq... | {
return buf;
} | conditional_block |
no_0014_longest_common_prefix.rs | struct Solution;
impl Solution {
pub fn | (strs: Vec<String>) -> String {
match strs.len() {
0 => return String::new(),
1 => return strs[0].clone(),
_ => (),
};
let mut buf = String::new();
for (i, c) in strs[0].as_bytes().iter().enumerate() {
for j in 1..strs.len() {
... | longest_common_prefix | identifier_name |
parse_movie.rs | // Copyright (c) 2017 Simon Dickson
//
// 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 std::path::Path;
use failure::Error;
use regex::Regex;
use data::Movie;... | Some (cap) => {
let title = cap.get(1).map(|m| m.as_str()).ok_or(format_err!("failed to parse title"))?;
Ok((title, None))
},
None => {
Ok((folder_name, None))
},
}
},
}
}
... | {
lazy_static! {
static ref TITLE_FORMAT_1: Regex = Regex::new(r"([^']+)\s+\((\d{4})\)").unwrap();
}
lazy_static! {
static ref TITLE_FORMAT_2: Regex = Regex::new(r"([^']+)\.").unwrap();
}
let folder_name =
path.strip_prefix(base_path)?.components().next().ok_or(format_err!("... | identifier_body |
parse_movie.rs | // Copyright (c) 2017 Simon Dickson
//
// 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 std::path::Path;
use failure::Error;
use regex::Regex;
use data::Movie;... | } | random_line_split | |
parse_movie.rs | // Copyright (c) 2017 Simon Dickson
//
// 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 std::path::Path;
use failure::Error;
use regex::Regex;
use data::Movie;... | (){
match parse(Path::new("/storage/movies/"), Path::new("/storage/movies/Great Escape.m4v")) {
Ok(Movie { ref title, year: None,.. }) if title == "Great Escape" => (),
result => assert!(false, "{:?}", result)
}
}
#[test]
fn die_hard(){
match parse(Path::new("/storage/movies/"), Path::new("... | great_escape | identifier_name |
eth_pubsub.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... |
})
.map_err(|e| warn!("Unable to fetch latest logs: {:?}", e))
);
}
}
}
/// A light client wrapper struct.
pub trait LightClient: Send + Sync {
/// Get a recent block header.
fn block_header(&self, id: BlockId) -> Option<encoded::Header>;
/// Fetch logs.
fn logs(&self, filter: EthFilter) -> BoxFutu... | {
Self::notify(&remote, &subscriber, pubsub::Result::Logs(logs));
} | conditional_block |
eth_pubsub.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... | (
&self,
_meta: Metadata,
subscriber: Subscriber<pubsub::Result>,
kind: pubsub::Kind,
params: Trailing<pubsub::Params>,
) {
match (kind, params.into()) {
(pubsub::Kind::NewHeads, None) => {
self.heads_subscribers.write().push(subscriber)
},
(pubsub::Kind::Logs, Some(pubsub::Params::Logs(filter... | subscribe | identifier_name |
eth_pubsub.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... |
fn notify_logs<F>(&self, enacted: &[H256], logs: F) where
F: Fn(EthFilter) -> BoxFuture<Vec<Log>, Error>,
{
for &(ref subscriber, ref filter) in self.logs_subscribers.read().values() {
let logs = futures::future::join_all(enacted
.iter()
.map(|hash| {
let mut filter = filter.clone();
filter... | {
for subscriber in self.heads_subscribers.read().values() {
for &(ref header, ref extra_info) in headers {
Self::notify(&self.remote, subscriber, pubsub::Result::Header(RichHeader {
inner: header.into(),
extra_info: extra_info.clone(),
}));
}
}
} | identifier_body |
eth_pubsub.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... | .notify(Ok(result))
.map(|_| ())
.map_err(|e| warn!(target: "rpc", "Unable to send notification: {}", e))
);
}
fn notify_heads(&self, headers: &[(encoded::Header, BTreeMap<String, String>)]) {
for subscriber in self.heads_subscribers.read().values() {
for &(ref header, ref extra_info) in headers {
... | remote.spawn(subscriber | random_line_split |
mutability-inherits-through-fixed-length-vec.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 ... | for i in ints.iter_mut() { *i += 22; }
for i in ints.iter() { assert!(*i == 22); }
}
pub fn main() {
test1();
test2();
} | }
fn test2() {
let mut ints = [0i, ..32]; | random_line_split |
mutability-inherits-through-fixed-length-vec.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
fn test2() {
let mut ints = [0i,..32];
for i in ints.iter_mut() { *i += 22; }
for i in ints.iter() { assert!(*i == 22); }
}
pub fn main() {
test1();
test2();
}
| {
let mut ints = [0i, ..32];
ints[0] += 1;
assert_eq!(ints[0], 1);
} | identifier_body |
mutability-inherits-through-fixed-length-vec.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 mut ints = [0i,..32];
for i in ints.iter_mut() { *i += 22; }
for i in ints.iter() { assert!(*i == 22); }
}
pub fn main() {
test1();
test2();
}
| test2 | identifier_name |
lib.rs | pub mod math;
pub mod objective;
pub mod tableau;
use math::variables::is_gen_arti_var;
use objective::problems::ProblemType;
use objective::functions::Function;
use objective::constraints::SystemOfConstraints;
use objective::solvers::{transform_constraint_rels_to_eq, rearrange_fun_eq_zero};
use tableau::tables::Table... | } else {
// Carry on with Phase II.
let mut table = get_initial_table_from(function, constraints);
return run_simplex(function, &mut table);
}
}
fn run_simplex(function: &Function, table: &mut Table) -> Vec<(String, Num)> {
loop {
match table.get_basic_solution() {
... | random_line_split | |
lib.rs | pub mod math;
pub mod objective;
pub mod tableau;
use math::variables::is_gen_arti_var;
use objective::problems::ProblemType;
use objective::functions::Function;
use objective::constraints::SystemOfConstraints;
use objective::solvers::{transform_constraint_rels_to_eq, rearrange_fun_eq_zero};
use tableau::tables::Table... |
}
fn run_simplex(function: &Function, table: &mut Table) -> Vec<(String, Num)> {
loop {
match table.get_basic_solution() {
Ok(mut basic_solution) => {
if table.is_solution_optimal() {
if function.p_type() == &ProblemType::MIN {
// Giv... | {
// Carry on with Phase II.
let mut table = get_initial_table_from(function, constraints);
return run_simplex(function, &mut table);
} | conditional_block |
lib.rs | pub mod math;
pub mod objective;
pub mod tableau;
use math::variables::is_gen_arti_var;
use objective::problems::ProblemType;
use objective::functions::Function;
use objective::constraints::SystemOfConstraints;
use objective::solvers::{transform_constraint_rels_to_eq, rearrange_fun_eq_zero};
use tableau::tables::Table... | }
} else {
panic!("Could not find a feasible solution to start Phase II.");
}
} else {
// Carry on with Phase II.
let mut table = get_initial_table_from(function, constraints);
return run_simplex(function, &mut table);
}
}
fn run_simplex(function... | {
rearrange_fun_eq_zero(function);
if let Some(mut phase1_fun) = transform_constraint_rels_to_eq(constraints) {
rearrange_fun_eq_zero(&mut phase1_fun);
let mut phase1_table = get_initial_table_from(function, constraints);
// Set Phase I function to work with.
append_function(&pha... | identifier_body |
lib.rs | pub mod math;
pub mod objective;
pub mod tableau;
use math::variables::is_gen_arti_var;
use objective::problems::ProblemType;
use objective::functions::Function;
use objective::constraints::SystemOfConstraints;
use objective::solvers::{transform_constraint_rels_to_eq, rearrange_fun_eq_zero};
use tableau::tables::Table... | (function: &Function, table: &mut Table) -> Vec<(String, Num)> {
loop {
match table.get_basic_solution() {
Ok(mut basic_solution) => {
if table.is_solution_optimal() {
if function.p_type() == &ProblemType::MIN {
// Give solution for MIN... | run_simplex | identifier_name |
input_test.rs | //! Example that just prints out all the input events.
use ggez::event::{self, Axis, Button, GamepadId, KeyCode, KeyMods, MouseButton};
use ggez::graphics::{self, Color, DrawMode};
use ggez::{conf, input};
use ggez::{Context, GameResult};
use glam::*;
struct MainState {
pos_x: f32,
pos_y: f32,
mouse_down:... |
}
}
pub fn main() -> GameResult {
let cb = ggez::ContextBuilder::new("input_test", "ggez").window_mode(
conf::WindowMode::default()
.fullscreen_type(conf::FullscreenType::Windowed)
.resizable(true),
);
let (ctx, event_loop) = cb.build()?;
// remove the comment to see... | {
println!("Focus lost");
} | conditional_block |
input_test.rs | //! Example that just prints out all the input events.
use ggez::event::{self, Axis, Button, GamepadId, KeyCode, KeyMods, MouseButton};
use ggez::graphics::{self, Color, DrawMode};
use ggez::{conf, input};
use ggez::{Context, GameResult};
use glam::*;
struct MainState {
pos_x: f32,
pos_y: f32,
mouse_down:... | (&mut self, _ctx: &mut Context, ch: char) {
println!("Text input: {}", ch);
}
fn gamepad_button_down_event(&mut self, _ctx: &mut Context, btn: Button, id: GamepadId) {
println!("Gamepad button pressed: {:?} Gamepad_Id: {:?}", btn, id);
}
fn gamepad_button_up_event(&mut self, _ctx: &mut... | text_input_event | identifier_name |
input_test.rs | //! Example that just prints out all the input events.
use ggez::event::{self, Axis, Button, GamepadId, KeyCode, KeyMods, MouseButton};
use ggez::graphics::{self, Color, DrawMode};
use ggez::{conf, input};
use ggez::{Context, GameResult};
use glam::*;
struct MainState {
pos_x: f32,
pos_y: f32,
mouse_down:... | println!("Key released: {:?}, modifier {:?}", keycode, keymod);
}
fn text_input_event(&mut self, _ctx: &mut Context, ch: char) {
println!("Text input: {}", ch);
}
fn gamepad_button_down_event(&mut self, _ctx: &mut Context, btn: Button, id: GamepadId) {
println!("Gamepad button ... | keycode, keymod, repeat
);
}
fn key_up_event(&mut self, _ctx: &mut Context, keycode: KeyCode, keymod: KeyMods) { | random_line_split |
input_test.rs | //! Example that just prints out all the input events.
use ggez::event::{self, Axis, Button, GamepadId, KeyCode, KeyMods, MouseButton};
use ggez::graphics::{self, Color, DrawMode};
use ggez::{conf, input};
use ggez::{Context, GameResult};
use glam::*;
struct MainState {
pos_x: f32,
pos_y: f32,
mouse_down:... | {
let cb = ggez::ContextBuilder::new("input_test", "ggez").window_mode(
conf::WindowMode::default()
.fullscreen_type(conf::FullscreenType::Windowed)
.resizable(true),
);
let (ctx, event_loop) = cb.build()?;
// remove the comment to see how physical mouse coordinates can ... | identifier_body | |
uuid.rs | #![allow(clippy::needless_lifetimes)]
use uuid::Uuid;
use crate::{
parser::{ParseError, ScalarToken, Token},
value::ParseScalarResult,
Value,
};
#[crate::graphql_scalar(description = "Uuid")]
impl<S> GraphQLScalar for Uuid
where
S: ScalarValue,
{
fn resolve(&self) -> Value {
Value::scalar... | assert_eq!(parsed, id);
}
} | random_line_split | |
uuid.rs | #![allow(clippy::needless_lifetimes)]
use uuid::Uuid;
use crate::{
parser::{ParseError, ScalarToken, Token},
value::ParseScalarResult,
Value,
};
#[crate::graphql_scalar(description = "Uuid")]
impl<S> GraphQLScalar for Uuid
where
S: ScalarValue,
{
fn resolve(&self) -> Value {
Value::scalar... | else {
Err(ParseError::UnexpectedToken(Token::Scalar(value)))
}
}
}
#[cfg(test)]
mod test {
use crate::{value::DefaultScalarValue, InputValue};
use uuid::Uuid;
#[test]
fn uuid_from_input_value() {
let raw = "123e4567-e89b-12d3-a456-426655440000";
let input: Inp... | {
Ok(S::from(value.to_owned()))
} | conditional_block |
uuid.rs | #![allow(clippy::needless_lifetimes)]
use uuid::Uuid;
use crate::{
parser::{ParseError, ScalarToken, Token},
value::ParseScalarResult,
Value,
};
#[crate::graphql_scalar(description = "Uuid")]
impl<S> GraphQLScalar for Uuid
where
S: ScalarValue,
{
fn resolve(&self) -> Value {
Value::scalar... | (v: &InputValue) -> Option<Uuid> {
v.as_string_value().and_then(|s| Uuid::parse_str(s).ok())
}
fn from_str<'a>(value: ScalarToken<'a>) -> ParseScalarResult<'a, S> {
if let ScalarToken::String(value) = value {
Ok(S::from(value.to_owned()))
} else {
Err(ParseError:... | from_input_value | identifier_name |
uuid.rs | #![allow(clippy::needless_lifetimes)]
use uuid::Uuid;
use crate::{
parser::{ParseError, ScalarToken, Token},
value::ParseScalarResult,
Value,
};
#[crate::graphql_scalar(description = "Uuid")]
impl<S> GraphQLScalar for Uuid
where
S: ScalarValue,
{
fn resolve(&self) -> Value {
Value::scalar... |
}
#[cfg(test)]
mod test {
use crate::{value::DefaultScalarValue, InputValue};
use uuid::Uuid;
#[test]
fn uuid_from_input_value() {
let raw = "123e4567-e89b-12d3-a456-426655440000";
let input: InputValue<DefaultScalarValue> = InputValue::scalar(raw.to_string());
let parsed: Uu... | {
if let ScalarToken::String(value) = value {
Ok(S::from(value.to_owned()))
} else {
Err(ParseError::UnexpectedToken(Token::Scalar(value)))
}
} | identifier_body |
path-lookahead.rs | // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () {
}
| main | identifier_name |
path-lookahead.rs | // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
fn main() {
}
| { //~WARN function is never used: `no_parens`
return <T as ToString>::to_string(&arg);
} | identifier_body |
path-lookahead.rs | // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
fn with_parens<T: ToString>(arg: T) -> String { //~WARN function is never used: `with_parens`
return (<T as ToString>::to_string(&arg)); //~WARN unnecessary parentheses around `return` value
}
fn no_parens<T: ToString>(arg: T) -> String { //~WARN function is never used: `no_parens`
return <T as ToString>::to_stri... | // Parser test for #37765 | random_line_split |
error.rs | // Copyright 2021 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
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in ... | pub enum SgeError {
IO(std::io::Error),
StdErr(Box<dyn std::error::Error>),
Literal(&'static str),
Message(String),
}
pub type SgeResult<T> = Result<T, SgeError>;
impl From<std::io::Error> for SgeError {
fn from(e: std::io::Error) -> Self {
SgeError::IO(e)
}
}
impl From<Box<dyn std::e... | random_line_split | |
error.rs | // Copyright 2021 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
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in ... | (self) -> &'static str {
match self {
SgeError::IO(_) => "io error",
SgeError::StdErr(_) => "std err",
SgeError::Literal(_) => "literal",
SgeError::Message(_) => "message",
}
}
}
impl std::error::Error for SgeError {
fn source(&self) -> Option<&(d... | into | identifier_name |
error.rs | // Copyright 2021 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
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in ... |
}
impl From<Box<dyn std::error::Error>> for SgeError {
fn from(e: Box<dyn std::error::Error>) -> Self {
SgeError::StdErr(e)
}
}
impl From<&'static str> for SgeError {
fn from(e: &'static str) -> Self {
SgeError::Literal(e)
}
}
impl From<String> for SgeError {
fn from(e: String) -... | {
SgeError::IO(e)
} | identifier_body |
parser-unicode-whitespace.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.
// | // 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.
// Beware editing: it has numerous whitespace characters which are important.
// It con... | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | random_line_split |
parser-unicode-whitespace.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 ... | {
assert_eq!(4+
7 * 2
/3*
2
, 4 + 7 * 2 / 3 * 2);
}
| identifier_body | |
parser-unicode-whitespace.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 ... | () {
assert_eq!(4+
7 * 2
/3*
2
, 4 + 7 * 2 / 3 * 2);
}
| main | identifier_name |
test.rs | // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | fn main() {
let program = r#"
#[no_mangle]
pub static TEST_STATIC: i32 = 42;
"#;
let program2 = r#"
#[no_mangle]
pub fn test_add(a: i32, b: i32) -> i32 { a + b }
"#;
let mut path = match std::env::args().nth(2) {
Some(path) => PathBuf::from(&path),
None => panic!("m... | random_line_split | |
test.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 ast_map = driver::assign_node_ids_and_map(&sess, &mut forest);
driver::phase_3_run_analysis_passes(
sess, ast_map, &arenas, id, MakeGlobMap::No, |tcx, analysis| {
let trans = driver::phase_4_translate_to_llvm(tcx, analysis);
let crates = tcx.sess.cstore.get_use... | {
let input = Input::Str(input.to_string());
let thread = Builder::new().name("compile_program".to_string());
let handle = thread.spawn(move || {
let opts = build_exec_options(sysroot);
let sess = build_session(opts, None, Registry::new(&rustc::DIAGNOSTICS));
rustc_lint::register_bu... | identifier_body |
test.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 ... | (input: &str, sysroot: PathBuf)
-> Option<(llvm::ModuleRef, Vec<PathBuf>)> {
let input = Input::Str(input.to_string());
let thread = Builder::new().name("compile_program".to_string());
let handle = thread.spawn(move || {
let opts = build_exec_options(sysroot);
let sess = ... | compile_program | identifier_name |
function_wrapper_cpp.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... | use super::type_to_cpp::{type_to_cpp, CppNameMap};
impl TypeConversionPolicy {
pub(super) fn unconverted_type(
&self,
cpp_name_map: &CppNameMap,
) -> Result<String, ConvertError> {
match self.cpp_conversion {
CppConversionType::FromUniquePtrToValue => self.wrapped_type(cpp_n... | random_line_split | |
function_wrapper_cpp.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... |
}
| {
Ok(match self.cpp_conversion {
CppConversionType::None => {
if type_lacks_copy_constructor(&self.unwrapped_type) && !use_rvo {
format!("std::move({})", var_name)
} else {
var_name.to_string()
}
}
... | identifier_body |
function_wrapper_cpp.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... | (&self, cpp_name_map: &CppNameMap) -> Result<String, ConvertError> {
match self.cpp_conversion {
CppConversionType::FromValueToUniquePtr => self.wrapped_type(cpp_name_map),
_ => self.unwrapped_type_as_string(cpp_name_map),
}
}
fn unwrapped_type_as_string(&self, cpp_name_... | converted_type | identifier_name |
task-comm-13.rs | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | while i < number_of_messages { tx.send(start + i); i += 1; }
}
pub fn main() {
println!("Check that we don't deadlock.");
let (tx, rx) = channel();
task::try(proc() { start(&tx, 0, 10) });
println!("Joined task");
} | use std::task;
fn start(tx: &Sender<int>, start: int, number_of_messages: int) {
let mut i: int = 0; | random_line_split |
task-comm-13.rs | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... |
pub fn main() {
println!("Check that we don't deadlock.");
let (tx, rx) = channel();
task::try(proc() { start(&tx, 0, 10) });
println!("Joined task");
}
| {
let mut i: int = 0;
while i < number_of_messages { tx.send(start + i); i += 1; }
} | identifier_body |
task-comm-13.rs | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | () {
println!("Check that we don't deadlock.");
let (tx, rx) = channel();
task::try(proc() { start(&tx, 0, 10) });
println!("Joined task");
}
| main | identifier_name |
config.rs | use std::io::Read;
use std;
use serde_json;
#[derive(Serialize, Deserialize)]
pub struct ConfigData{
pub username:String,
pub password:String,
pub channels:Vec<String>,
pub admins:Vec<String>,
pub nyaa:Nyaa,
}
#[derive(Serialize, Deserialize,Clone)]
pub struct Nyaa{
pub delay:u64,
}
#[derive(... | assert_eq!("name",cd.username());
assert_eq!("oauth:1234",cd.password());
assert_eq!("___4Header",cd.channels()[0]);
assert_eq!("PagChomp",cd.channels()[1]);
assert_eq!("Keepo",cd.channels()[2]);
assert_eq!(3,cd.channels().len());
assert_eq!("443297327",cd.admins(... | let mut cd = ConfigData::new("tests/config_test.json").unwrap(); | random_line_split |
config.rs | use std::io::Read;
use std;
use serde_json;
#[derive(Serialize, Deserialize)]
pub struct ConfigData{
pub username:String,
pub password:String,
pub channels:Vec<String>,
pub admins:Vec<String>,
pub nyaa:Nyaa,
}
#[derive(Serialize, Deserialize,Clone)]
pub struct | {
pub delay:u64,
}
#[derive(Debug)]
pub enum ConfigErr{
Parse,
Open,
Read
}
impl ConfigData{
pub fn new(file: &str)->Result<ConfigData,ConfigErr>{
let s = try!(file_to_string(file));
serde_json::from_str(&s).map_err(|_|ConfigErr::Parse)
}
}
fn file_to_string(file: &str)->Res... | Nyaa | identifier_name |
mv.rs | use board::chess::board::*;
use pgn_traits::pgn::PgnBoard;
use board_game_traits::board::Board;
|
#[derive(Clone, Eq, PartialEq, Debug)]
pub struct ChessReverseMove {
pub from : Square,
pub to : Square,
pub capture : PieceType,
pub prom : bool,
pub old_castling_en_passant : u8,
pub old_half_move_clock : u8,
pub old_past_move_hashes: Option<Vec<u64>>,
}
impl ChessReverseMove {
/// R... | use std::fmt; | random_line_split |
mv.rs | use board::chess::board::*;
use pgn_traits::pgn::PgnBoard;
use board_game_traits::board::Board;
use std::fmt;
#[derive(Clone, Eq, PartialEq, Debug)]
pub struct ChessReverseMove {
pub from : Square,
pub to : Square,
pub capture : PieceType,
pub prom : bool,
pub old_castling_en_passant : u8,
pub... | (&self, fmt : &mut fmt::Formatter) -> Result<(), fmt::Error> {
fmt.write_str(&format!("{}", ChessBoard::start_board().move_to_lan(self))).unwrap();
Ok(())
}
}
impl fmt::Debug for ChessMove {
fn fmt(&self, fmt : &mut fmt::Formatter) -> Result<(), fmt::Error> {
fmt::Display::fmt(self, fmt... | fmt | identifier_name |
tests.rs | use rocket::testing::MockRequest;
use rocket::http::Method::*;
use rocket::http::{ContentType, Status};
use super::rocket;
fn test_login(username: &str, password: &str, age: isize, status: Status,
body: Option<&'static str>) {
let rocket = rocket();
let mut req = MockRequest::new(Post, "/login")... |
#[test]
fn test_bad_form() {
check_bad_form("&", Status::BadRequest);
check_bad_form("=", Status::BadRequest);
check_bad_form("&&&===&", Status::BadRequest);
check_bad_form("username=Sergio", Status::UnprocessableEntity);
check_bad_form("username=Sergio&", Status::UnprocessableEntity);
check_... | {
let rocket = rocket();
let mut req = MockRequest::new(Post, "/login")
.header(ContentType::Form)
.body(form_str);
let response = req.dispatch_with(&rocket);
assert_eq!(response.status(), status);
} | identifier_body |
tests.rs | use rocket::testing::MockRequest;
use rocket::http::Method::*;
use rocket::http::{ContentType, Status};
use super::rocket;
fn test_login(username: &str, password: &str, age: isize, status: Status,
body: Option<&'static str>) {
let rocket = rocket();
let mut req = MockRequest::new(Post, "/login")... | () {
test_login("Sergio", "password", 30, Status::SeeOther, None);
}
const OK: Status = self::Status::Ok;
#[test]
fn test_bad_login() {
test_login("Sergio", "password", 20, OK, Some("Sorry, 20 is too young!"));
test_login("Sergio", "password", 200, OK, Some("Are you sure you're 200?"));
test_login("Se... | test_good_login | identifier_name |
tests.rs | use rocket::testing::MockRequest;
use rocket::http::Method::*;
use rocket::http::{ContentType, Status};
use super::rocket;
fn test_login(username: &str, password: &str, age: isize, status: Status,
body: Option<&'static str>) {
let rocket = rocket();
let mut req = MockRequest::new(Post, "/login")... |
}
#[test]
fn test_good_login() {
test_login("Sergio", "password", 30, Status::SeeOther, None);
}
const OK: Status = self::Status::Ok;
#[test]
fn test_bad_login() {
test_login("Sergio", "password", 20, OK, Some("Sorry, 20 is too young!"));
test_login("Sergio", "password", 200, OK, Some("Are you sure you'... | {
assert!(body_str.map_or(true, |s| s.contains(string)));
} | conditional_block |
tests.rs | use rocket::testing::MockRequest;
use rocket::http::Method::*;
use rocket::http::{ContentType, Status};
use super::rocket;
fn test_login(username: &str, password: &str, age: isize, status: Status,
body: Option<&'static str>) {
let rocket = rocket();
let mut req = MockRequest::new(Post, "/login")... | #[test]
fn test_bad_login() {
test_login("Sergio", "password", 20, OK, Some("Sorry, 20 is too young!"));
test_login("Sergio", "password", 200, OK, Some("Are you sure you're 200?"));
test_login("Sergio", "jk", -100, OK, Some("'-100' is not a valid integer."));
test_login("Sergio", "ok", 30, OK, Some("Wro... | }
const OK: Status = self::Status::Ok;
| random_line_split |
build.rs | #![warn(rust_2018_idioms)]
use std::env;
include!("no_atomic.rs");
// The rustc-cfg listed below are considered public API, but it is *unstable*
// and outside of the normal semver guarantees:
//
// - `crossbeam_no_atomic_cas`
// Assume the target does *not* support atomic CAS operations.
// This is usuall... |
println!("cargo:rerun-if-changed=no_atomic.rs");
}
| {
let target = match env::var("TARGET") {
Ok(target) => target,
Err(e) => {
println!(
"cargo:warning={}: unable to get TARGET environment variable: {}",
env!("CARGO_PKG_NAME"),
e
);
return;
}
};
// N... | identifier_body |
build.rs | #![warn(rust_2018_idioms)]
use std::env;
include!("no_atomic.rs");
// The rustc-cfg listed below are considered public API, but it is *unstable*
// and outside of the normal semver guarantees:
//
// - `crossbeam_no_atomic_cas`
// Assume the target does *not* support atomic CAS operations.
// This is usuall... | () {
let target = match env::var("TARGET") {
Ok(target) => target,
Err(e) => {
println!(
"cargo:warning={}: unable to get TARGET environment variable: {}",
env!("CARGO_PKG_NAME"),
e
);
return;
}
};
/... | main | identifier_name |
build.rs | #![warn(rust_2018_idioms)]
use std::env;
include!("no_atomic.rs");
// The rustc-cfg listed below are considered public API, but it is *unstable*
// and outside of the normal semver guarantees:
//
// - `crossbeam_no_atomic_cas`
// Assume the target does *not* support atomic CAS operations.
// This is usuall... | Err(e) => {
println!(
"cargo:warning={}: unable to get TARGET environment variable: {}",
env!("CARGO_PKG_NAME"),
e
);
return;
}
};
// Note that this is `no_*`, not `has_*`. This allows treating
// `cfg(targe... | fn main() {
let target = match env::var("TARGET") {
Ok(target) => target, | random_line_split |
lr.template.rs | #![allow(dead_code)]
#![allow(unused_mut)]
#![allow(unreachable_code)]
extern crate onig;
#[macro_use]
extern crate lazy_static;
use onig::{Regex, Syntax, RegexOptions};
use std::collections::HashMap;
/**
* Stack value.
*/
enum SV {
Undefined,
{{{SV_ENUM}}}
}
/**
* Lex rules.
*/
static LEX_RULES: {{{LE... |
let entry = &TABLE[state][&column];
match entry {
// Shift a token, go to state.
&TE::Shift(next_state) => {
// Push token.
self.values_stack.push(SV::_0(token));
// Push next state number: "s5" -> 5... | {
self.unexpected_token(&token);
break;
} | conditional_block |
lr.template.rs | #![allow(dead_code)]
#![allow(unused_mut)]
#![allow(unreachable_code)]
extern crate onig;
#[macro_use]
extern crate lazy_static;
use onig::{Regex, Syntax, RegexOptions};
use std::collections::HashMap;
/**
* Stack value.
*/
enum SV {
Undefined,
{{{SV_ENUM}}}
}
/**
* Lex rules.
*/
static LEX_RULES: {{{LE... | {
Accept,
// Shift, and transit to the state.
Shift(usize),
// Reduce by a production number.
Reduce(usize),
// Simple state transition.
Transit(usize),
}
lazy_static! {
/**
* Lexical rules grouped by lexer state (by start condition).
*/
static ref LEX_RULES_BY_START_C... | TE | identifier_name |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.