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 |
|---|---|---|---|---|
promote.rs | use crate::{api_client,
common::ui::{Status,
UIReader,
UIWriter,
UI},
error::{Error,
Result},
hcore::{package::PackageIdent,
ChannelIdent},
PRODUCT,
... |
pub fn get_ident_list(ui: &mut UI,
group_status: &api_client::SchedulerResponse,
origin: Option<&str>,
interactive: bool)
-> Result<Vec<String>> {
let mut idents: Vec<String> =
group_status.projects
.... | origin.map_or(true, |o| PackageIdent::from_str(ident).unwrap().origin == o)
} | random_line_split |
promote.rs | use crate::{api_client,
common::ui::{Status,
UIReader,
UIWriter,
UI},
error::{Error,
Result},
hcore::{package::PackageIdent,
ChannelIdent},
PRODUCT,
... | (ui: &mut UI,
group_status: &api_client::SchedulerResponse,
origin: Option<&str>,
interactive: bool)
-> Result<Vec<String>> {
let mut idents: Vec<String> =
group_status.projects
.iter()
... | get_ident_list | identifier_name |
effect.rs | use types::monster::StatType;
use base::statmod::StatModifiers;
use types::monster::ExperienceType;
use base::runner::BattleFlagsType;
use base::runner::{BattleEffects, BattleState};
use calculate::lingering::LingeringType;
#[derive(Debug, PartialEq)]
pub enum Effect
{
Damage(Damage),
Switch(Switch),
Retreat(Ret... | /// Returns `true` by default.
///
fn state_change(&mut self) -> bool
{
true
}
// TODO: Effects may be activated upon creation.
/// Activates after the object was created.
fn after_create(&mut self, state: &BattleState);
/// Activates at the end of a turn. Returns `true` to change state.
///
/// Returns ... | random_line_split | |
effect.rs | use types::monster::StatType;
use base::statmod::StatModifiers;
use types::monster::ExperienceType;
use base::runner::BattleFlagsType;
use base::runner::{BattleEffects, BattleState};
use calculate::lingering::LingeringType;
#[derive(Debug, PartialEq)]
pub enum Effect
{
Damage(Damage),
Switch(Switch),
Retreat(Ret... |
{
pub party: usize,
pub member: usize,
pub amount: ExperienceType,
// Original level of the party member.
pub level: u8,
}
impl ExperienceGain
{
pub fn new(party: usize, member: usize, amount: ExperienceType, level: u8) -> Self
{
ExperienceGain
{
party: party,
member: member,
amount: amount,
le... | ExperienceGain | identifier_name |
effect.rs | use types::monster::StatType;
use base::statmod::StatModifiers;
use types::monster::ExperienceType;
use base::runner::BattleFlagsType;
use base::runner::{BattleEffects, BattleState};
use calculate::lingering::LingeringType;
#[derive(Debug, PartialEq)]
pub enum Effect
{
Damage(Damage),
Switch(Switch),
Retreat(Ret... |
// TODO: Effects may be activated upon creation.
/// Activates after the object was created.
fn after_create(&mut self, state: &BattleState);
/// Activates at the end of a turn. Returns `true` to change state.
///
/// Returns `false` by default.
///
fn after_turn(&self) -> bool
{
false
}
}
#[derive(Debu... | {
true
} | identifier_body |
iris.rs | ///
/// This example parses, sorts and groups the iris dataset
/// and does some simple manipulations.
///
/// Iterators and itertools functionality are used throughout.
use itertools::Itertools;
use std::collections::HashMap;
use std::iter::repeat;
use std::num::ParseFloatError;
use std::str::FromStr;
static DATA: &... | data.iter()
.map(|iris| iris.data[col])
.minmax()
.into_option()
.expect("Can't find min/max of empty iterator")
};
let (min_x, max_x) = min_max(&irises, a);
let (min_y, max_y) = min_max(&irises, b);
// Plot the dat... | plot.iter_mut().set_from(repeat(' '));
// using Itertools::minmax
let min_max = |data: &[Iris], col| { | random_line_split |
iris.rs | ///
/// This example parses, sorts and groups the iris dataset
/// and does some simple manipulations.
///
/// Iterators and itertools functionality are used throughout.
use itertools::Itertools;
use std::collections::HashMap;
use std::iter::repeat;
use std::num::ParseFloatError;
use std::str::FromStr;
static DATA: &... | (err: ParseFloatError) -> Self {
ParseError::Numeric(err)
}
}
/// Parse an Iris from a comma-separated line
impl FromStr for Iris {
type Err = ParseError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
let mut iris = Iris { name: "".into(), data: [0.; 4] };
let mut parts = s.spl... | from | identifier_name |
iris.rs | ///
/// This example parses, sorts and groups the iris dataset
/// and does some simple manipulations.
///
/// Iterators and itertools functionality are used throughout.
use itertools::Itertools;
use std::collections::HashMap;
use std::iter::repeat;
use std::num::ParseFloatError;
use std::str::FromStr;
static DATA: &... |
Ok(data) => data,
};
// Sort them and group them
irises.sort_by(|a, b| Ord::cmp(&a.name, &b.name));
// using Iterator::cycle()
let mut plot_symbols = "+ox".chars().cycle();
let mut symbolmap = HashMap::new();
// using Itertools::group_by
for (species, species_group) in &irise... | {
println!("Error parsing: {:?}", e);
std::process::exit(1);
} | conditional_block |
toggle.rs | // Copyright 2020 The Exonum Team
//
// 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 i... | break;
} else if Instant::now() - start_time > MAX_WAIT {
panic!("Node did not achieve {:?}", EXPECTED_HEIGHT);
}
delay_for(MAX_WAIT / 20).await;
}
node.join().await;
}
} | let start_time = Instant::now();
loop {
let last_block = node.blockchain().last_block();
if last_block.height > EXPECTED_HEIGHT { | random_line_split |
toggle.rs | // Copyright 2020 The Exonum Team
//
// 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 i... | (self) -> ApiStats {
drop(self.cancel_tx);
self.stats.await
}
}
/// Runs a network with a service that is frequently switched on / off and that generates
/// transactions in `after_commit` hook.
#[derive(Debug, StructOpt)]
#[structopt(name = "toggle", set_term_width = 80)]
struct Args {
/// Num... | get | identifier_name |
toggle.rs | // Copyright 2020 The Exonum Team
//
// 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 i... |
}
/// Periodically probes the node HTTP API, recording the number of times the response was
/// successful and erroneous. `cancel_rx` is used to signal probe termination.
async fn probe_api(url: &str, mut cancel_rx: oneshot::Receiver<()>) -> ApiStats {
const API_TIMEOUT: Duration = Duration::from_millis(50);
... | {
let mut debug_struct = formatter.debug_struct("ApiStats");
debug_struct
.field("ok_answers", &self.ok_answers)
.field("erroneous_answers", &self.erroneous_answers);
let all_answers = self.ok_answers + self.erroneous_answers;
if all_answers > 0 {
let... | identifier_body |
enter_vars.rs | use tableau::tables::Table;
pub fn enter_var_pivot_optimal(table: &Table) -> usize {
let table_rows = table.get_rows();
let last_row_index = table_rows.len() - 1;
// Select the most negative cell in the objective function row.
let mut column_index = 0;
for i in 0..table_rows[last_row_index].len() -... |
}
column_index
}
pub fn enter_var_pivot_feasible(table: &Table,
row: usize,
begin_column: usize)
-> Option<usize> {
let table_rows = table.get_rows();
// Select the positive cell furthest to the left.
f... | {
column_index = i;
} | conditional_block |
enter_vars.rs | use tableau::tables::Table;
pub fn enter_var_pivot_optimal(table: &Table) -> usize |
pub fn enter_var_pivot_feasible(table: &Table,
row: usize,
begin_column: usize)
-> Option<usize> {
let table_rows = table.get_rows();
// Select the positive cell furthest to the left.
for i in 0..begin_column {... | {
let table_rows = table.get_rows();
let last_row_index = table_rows.len() - 1;
// Select the most negative cell in the objective function row.
let mut column_index = 0;
for i in 0..table_rows[last_row_index].len() - 1 {
if table_rows[last_row_index][i] < table_rows[last_row_index][column_in... | identifier_body |
enter_vars.rs | use tableau::tables::Table;
pub fn enter_var_pivot_optimal(table: &Table) -> usize {
let table_rows = table.get_rows();
let last_row_index = table_rows.len() - 1;
// Select the most negative cell in the objective function row.
let mut column_index = 0;
for i in 0..table_rows[last_row_index].len() -... | }
pub fn enter_var_pivot_feasible(table: &Table,
row: usize,
begin_column: usize)
-> Option<usize> {
let table_rows = table.get_rows();
// Select the positive cell furthest to the left.
for i in 0..begin_column ... | }
}
column_index | random_line_split |
enter_vars.rs | use tableau::tables::Table;
pub fn | (table: &Table) -> usize {
let table_rows = table.get_rows();
let last_row_index = table_rows.len() - 1;
// Select the most negative cell in the objective function row.
let mut column_index = 0;
for i in 0..table_rows[last_row_index].len() - 1 {
if table_rows[last_row_index][i] < table_rows[... | enter_var_pivot_optimal | identifier_name |
mod.rs | // Copyright (c) 2015 Chris Palmer <pennstate5013@gmail.com>
// Use of this source code is governed by the GPLv3 license that can be
// found in the LICENSE file.
use std::io::prelude::*;
use std::io::BufReader;
use std::fs::File;
pub fn | (path_str: &str) -> Vec<String> {
let mut file_vec: Vec<String> = Vec::new();
let f = File::open(path_str).unwrap();
let reader = BufReader::new(f);
for line in reader.lines() {
file_vec.push(line.unwrap());
}
file_vec
}
pub fn get_version() -> &'static str {
"1.0.0"
}
pub fn ge... | read_to_vec | identifier_name |
mod.rs | // Copyright (c) 2015 Chris Palmer <pennstate5013@gmail.com>
// Use of this source code is governed by the GPLv3 license that can be
// found in the LICENSE file.
use std::io::prelude::*;
use std::io::BufReader;
use std::fs::File;
pub fn read_to_vec(path_str: &str) -> Vec<String> { |
for line in reader.lines() {
file_vec.push(line.unwrap());
}
file_vec
}
pub fn get_version() -> &'static str {
"1.0.0"
}
pub fn get_name() -> &'static str {
"file_compare"
}
pub fn get_author() -> &'static str {
"red-oxide <https://github.com/red-oxide/file_compare>"
}
pub fn get_a... | let mut file_vec: Vec<String> = Vec::new();
let f = File::open(path_str).unwrap();
let reader = BufReader::new(f); | random_line_split |
mod.rs | // Copyright (c) 2015 Chris Palmer <pennstate5013@gmail.com>
// Use of this source code is governed by the GPLv3 license that can be
// found in the LICENSE file.
use std::io::prelude::*;
use std::io::BufReader;
use std::fs::File;
pub fn read_to_vec(path_str: &str) -> Vec<String> {
let mut file_vec: Vec<String> =... |
pub fn get_author() -> &'static str {
"red-oxide <https://github.com/red-oxide/file_compare>"
}
pub fn get_about() -> &'static str {
"compare two files to see if lines in first file exist in the second file"
}
| {
"file_compare"
} | identifier_body |
main.rs | use std::collections::VecDeque;
use std::io::{self, Write};
fn haar_level(f: Vec<f64>) -> (Vec<f64>, Vec<f64>){
let mut a: Vec<f64> = Vec::new();
let mut d: Vec<f64> = Vec::new();
let base : f64 = 1.0f64 / 2.0f64.powf(0.5f64);
let n : usize = f.len() / 2;
for i in 0..n {
a.push(base*(f[2*i... | (f: Vec<f64>) -> VecDeque<Vec<f64>> {
let n = (f.len() as f64).log2().trunc() as u32;
println!("n {}", n);
let mut a: Vec<f64> = Vec::new();
let m = 2u32.pow(n) as usize;
for i in 0..m {
a.push(f[i]);
}
let mut res : VecDeque<Vec<f64>> = VecDeque::new();
while a.len() > 1 {
... | haar | identifier_name |
main.rs | use std::collections::VecDeque;
use std::io::{self, Write};
fn haar_level(f: Vec<f64>) -> (Vec<f64>, Vec<f64>){
let mut a: Vec<f64> = Vec::new();
let mut d: Vec<f64> = Vec::new();
let base : f64 = 1.0f64 / 2.0f64.powf(0.5f64);
let n : usize = f.len() / 2;
for i in 0..n {
a.push(base*(f[2*i... |
io::stdout().flush().unwrap();
}
fn print2(d : VecDeque<Vec<f64>>)
{
print!("[ ");
for i in d {
print(i, false);
}
print!(" ]\n");
io::stdout().flush().unwrap();
}
fn main() {
let data : Vec<f64> = vec![4.,6.,10.,12.,8.,6.,5.,5.];
print(data.clone(), true)... | {
print!("\n");
} | conditional_block |
main.rs | use std::collections::VecDeque;
use std::io::{self, Write};
fn haar_level(f: Vec<f64>) -> (Vec<f64>, Vec<f64>){
let mut a: Vec<f64> = Vec::new();
let mut d: Vec<f64> = Vec::new();
let base : f64 = 1.0f64 / 2.0f64.powf(0.5f64);
let n : usize = f.len() / 2;
for i in 0..n {
a.push(base*(f[2*i... |
}
fn main() {
let data : Vec<f64> = vec![4.,6.,10.,12.,8.,6.,5.,5.];
print(data.clone(), true);
let res = haar(data);
print2(res.clone());
print(inverse_haar(res.clone()), true);
} | print(i, false);
}
print!(" ]\n");
io::stdout().flush().unwrap(); | random_line_split |
main.rs | use std::collections::VecDeque;
use std::io::{self, Write};
fn haar_level(f: Vec<f64>) -> (Vec<f64>, Vec<f64>){
let mut a: Vec<f64> = Vec::new();
let mut d: Vec<f64> = Vec::new();
let base : f64 = 1.0f64 / 2.0f64.powf(0.5f64);
let n : usize = f.len() / 2;
for i in 0..n {
a.push(base*(f[2*i... | {
let data : Vec<f64> = vec![4.,6.,10.,12.,8.,6.,5.,5.];
print(data.clone(), true);
let res = haar(data);
print2(res.clone());
print(inverse_haar(res.clone()), true);
} | identifier_body | |
select_ok.rs | extern crate futures;
use futures::future::*;
#[test]
fn ignore_err() {
let v = vec![
err(1).boxed(),
err(2).boxed(),
ok(3).boxed(),
ok(4).boxed(),
];
let (i, v) = select_ok(v).wait().ok().unwrap();
assert_eq!(i, 3);
assert!(v.len() == 1);
let (i, v) = select... | {
let v = vec![
ok(1).boxed(),
err(2).boxed(),
err(3).boxed(),
];
let (i, v) = select_ok(v).wait().ok().unwrap();
assert_eq!(i, 1);
assert!(v.len() == 2);
let i = select_ok(v).wait().err().unwrap();
assert_eq!(i, 3);
} | identifier_body | |
select_ok.rs | extern crate futures;
use futures::future::*;
#[test]
fn ignore_err() {
let v = vec![
err(1).boxed(),
err(2).boxed(),
ok(3).boxed(),
ok(4).boxed(),
];
let (i, v) = select_ok(v).wait().ok().unwrap();
assert_eq!(i, 3);
assert!(v.len() == 1); |
let (i, v) = select_ok(v).wait().ok().unwrap();
assert_eq!(i, 4);
assert!(v.len() == 0);
}
#[test]
fn last_err() {
let v = vec![
ok(1).boxed(),
err(2).boxed(),
err(3).boxed(),
];
let (i, v) = select_ok(v).wait().ok().unwrap();
assert_eq!(i, 1);
assert!(v.len(... | random_line_split | |
select_ok.rs | extern crate futures;
use futures::future::*;
#[test]
fn ignore_err() {
let v = vec![
err(1).boxed(),
err(2).boxed(),
ok(3).boxed(),
ok(4).boxed(),
];
let (i, v) = select_ok(v).wait().ok().unwrap();
assert_eq!(i, 3);
assert!(v.len() == 1);
let (i, v) = select... | () {
let v = vec![
ok(1).boxed(),
err(2).boxed(),
err(3).boxed(),
];
let (i, v) = select_ok(v).wait().ok().unwrap();
assert_eq!(i, 1);
assert!(v.len() == 2);
let i = select_ok(v).wait().err().unwrap();
assert_eq!(i, 3);
}
| last_err | identifier_name |
root.rs | . 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/. */
//! Smart pointers for the JS-managed DOM objects.
//!
//! The DOM is made up of DOM objects whose lifetime is entirely controlled by
//! the whims of the SpiderMonkey garbage collector. The types ... | (&self, ops: &mut MallocSizeOfOps) -> usize {
(**self).size_of(ops)
}
}
impl<T> PartialEq for DomRoot<T>
where
T: DomObject,
{
fn eq(&self, other: &Self) -> bool {
self.value == other.value
}
}
impl<T> Clone for DomRoot<T>
where
T: DomObject,
{
fn clone(&self) -> DomRoot<T> {
... | size_of | identifier_name |
root.rs | 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/. */
//! Smart pointers for the JS-managed DOM objects.
//!
//! The DOM is made up of DOM objects whose lifetime is entirely controlled by
//! the whims of the SpiderMonkey garbage collector. The type... | }
/// A holder that provides interior mutability for GC-managed values such as
/// `Dom<T>`. Essentially a `Cell<Dom<T>>`, but safer.
///
/// This should only be used as a field in other DOM objects; see warning
/// on `Dom<T>`.
#[must_root]
#[derive(JSTraceable)]
pub struct MutDom<T: DomObject> {
val: UnsafeCell... | ptr: ptr::NonNull::new_unchecked(addr as *const Node as *mut Node),
}
} | random_line_split |
root.rs | . 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/. */
//! Smart pointers for the JS-managed DOM objects.
//!
//! The DOM is made up of DOM objects whose lifetime is entirely controlled by
//! the whims of the SpiderMonkey garbage collector. The types ... |
/// Stops tracking a trace object, asserting if it isn't found.
unsafe fn unroot(&self, object: *const dyn JSTraceable) {
debug_assert!(thread_state::get().is_script());
let roots = &mut *self.roots.get();
match roots.iter().rposition(|r| *r == object) {
Some(idx) => {
... | {
debug_assert!(thread_state::get().is_script());
(*self.roots.get()).push(object);
} | identifier_body |
A.rs |
fn main(){
let mut s = String::new();
std::io::stdin().read_line(&mut s).unwrap();
let n = s.trim().parse::<i32>().unwrap();
let mut s = String::new();
std::io::stdin().read_line(&mut s).unwrap();
let a = s.trim().parse::<i32>().unwrap();
let ten = ((n / 10) % 10) * 10 + (n % 10);
let hund = ((n / 100) % 10) *... | else if hyaku {
println!("{}", if a - (hund - 500) >= 0 { "Yes" } else { "No" });
} else {
println!("{}", if a - hund >= 0 { "Yes" } else { "No" });
}
}
| {
println!("{}", if a - ten >= 0 { "Yes" } else { "No" });
} | conditional_block |
A.rs | fn main(){
let mut s = String::new();
std::io::stdin().read_line(&mut s).unwrap();
let n = s.trim().parse::<i32>().unwrap();
let mut s = String::new();
std::io::stdin().read_line(&mut s).unwrap();
let a = s.trim().parse::<i32>().unwrap();
let ten = ((n / 10) % 10) * 10 + (n % 10); | let hund = ((n / 100) % 10) * 100 + ((n / 10) % 10) * 10 + (n % 10);
let hyaku = ((n / 100) % 10) > 5;
if ((n / 100) % 100) % 5 == 0 {
println!("{}", if a - ten >= 0 { "Yes" } else { "No" });
} else if hyaku {
println!("{}", if a - (hund - 500) >= 0 { "Yes" } else { "No" });
} else {
println!("{}", if a - hu... | random_line_split | |
A.rs |
fn | (){
let mut s = String::new();
std::io::stdin().read_line(&mut s).unwrap();
let n = s.trim().parse::<i32>().unwrap();
let mut s = String::new();
std::io::stdin().read_line(&mut s).unwrap();
let a = s.trim().parse::<i32>().unwrap();
let ten = ((n / 10) % 10) * 10 + (n % 10);
let hund = ((n / 100) % 10) * 100 + (... | main | identifier_name |
A.rs |
fn main() | {
let mut s = String::new();
std::io::stdin().read_line(&mut s).unwrap();
let n = s.trim().parse::<i32>().unwrap();
let mut s = String::new();
std::io::stdin().read_line(&mut s).unwrap();
let a = s.trim().parse::<i32>().unwrap();
let ten = ((n / 10) % 10) * 10 + (n % 10);
let hund = ((n / 100) % 10) * 100 + ((n... | identifier_body | |
buffer.rs | use buffer::{Content, BufferView, BufferViewAny, BufferType, BufferCreationError};
use uniforms::{AsUniformValue, UniformBlock, UniformValue, LayoutMismatchError};
use program;
use std::ops::{Deref, DerefMut};
use backend::Facade;
/// Buffer that contains a uniform block.
#[derive(Debug)]
pub struct | <T:?Sized> where T: Content {
buffer: BufferView<T>,
}
/// Same as `UniformBuffer` but doesn't contain any information about the type.
#[derive(Debug)]
pub struct TypelessUniformBuffer {
buffer: BufferViewAny,
}
impl<T> UniformBuffer<T> where T: Copy {
/// Uploads data in the uniforms buffer.
pub fn n... | UniformBuffer | identifier_name |
buffer.rs | use buffer::{Content, BufferView, BufferViewAny, BufferType, BufferCreationError};
use uniforms::{AsUniformValue, UniformBlock, UniformValue, LayoutMismatchError};
use program;
use std::ops::{Deref, DerefMut};
use backend::Facade;
/// Buffer that contains a uniform block.
#[derive(Debug)]
pub struct UniformBuffer<T:... |
}
impl<T:?Sized> Deref for UniformBuffer<T> where T: Content {
type Target = BufferView<T>;
fn deref(&self) -> &BufferView<T> {
&self.buffer
}
}
impl<T:?Sized> DerefMut for UniformBuffer<T> where T: Content {
fn deref_mut(&mut self) -> &mut BufferView<T> {
&mut self.buffer
}
}
i... | {
let buffer = try!(BufferView::empty_unsized(facade, BufferType::UniformBuffer, size, true));
Ok(UniformBuffer {
buffer: buffer,
})
} | identifier_body |
buffer.rs | use buffer::{Content, BufferView, BufferViewAny, BufferType, BufferCreationError};
use uniforms::{AsUniformValue, UniformBlock, UniformValue, LayoutMismatchError};
use program;
use std::ops::{Deref, DerefMut};
use backend::Facade;
/// Buffer that contains a uniform block.
#[derive(Debug)]
pub struct UniformBuffer<T:... | } | random_line_split | |
lib.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... | .with_status(StatusCode::BadRequest)
.with_header(ContentType::plaintext())
.with_body(reason)
}
};
if let Some(cors_header) = cors_header {
res.headers_mut().set(cors_header);
res.headers_mut().set(Vary::Items(vec![Ascii::new("Origin".into())]));
}
future::ok(res)
}
}
/// Add curren... | },
Out::Bad(reason) => {
hyper::Response::new() | random_line_split |
lib.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) -> &BlockChainClient {
&*self.client
}
pub fn new(cors: DomainsValidation<AccessControlAllowOrigin>, hosts: DomainsValidation<Host>, client: Arc<BlockChainClient>) -> Self {
IpfsHandler {
cors_domains: cors.into(),
allowed_hosts: hosts.into(),
client: client,
}
}
pub fn on_request(&self, req... | client | identifier_name |
complex.rs | extern crate iron;
extern crate session;
extern crate rustc_serialize;
use iron::prelude::*;
use session::*;
// To run, $ cargo run --example complex
// to use, $ curl "http://localhost:3000/login"
// $ curl "http://localhost:3000/show_count"
// $ curl "http://localhost:3000/reset_count"
// $ c... |
fn reset_count(req: &mut Request) -> IronResult<Response> {
req.remove_session("count").unwrap();
Ok(Response::with((iron::status::Ok, "count reset")))
}
| {
let mut count = req.get_session::<usize>("count").unwrap_or(0);
count += 1;
req.set_session("count", &count).unwrap();
Ok(Response::with((iron::status::Ok, format!("count:{}", &count))))
} | identifier_body |
complex.rs | extern crate iron;
extern crate session;
extern crate rustc_serialize;
use iron::prelude::*;
use session::*;
// To run, $ cargo run --example complex
// to use, $ curl "http://localhost:3000/login"
// $ curl "http://localhost:3000/show_count"
// $ curl "http://localhost:3000/reset_count"
// $ c... | () {
let mut chain = Chain::new(handle);
let signing_key = "key-123456";
let expire_seconds = 3600;
let connect_str = "redis://localhost";
chain.around(session::Session::new(signing_key, expire_seconds, connect_str));
Iron::new(chain).http("localhost:3000").unwrap();
}
fn get_action(req: &Reque... | main | identifier_name |
complex.rs | extern crate iron;
extern crate session;
extern crate rustc_serialize;
use iron::prelude::*;
use session::*;
// To run, $ cargo run --example complex
// to use, $ curl "http://localhost:3000/login"
// $ curl "http://localhost:3000/show_count"
// $ curl "http://localhost:3000/reset_count"
// $ c... | } | random_line_split | |
actions.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
use std::collections::hash_map::Entry;
use std::collections::HashMap;
use std::fmt;
use std::ops::Deref;
use std::ops::DerefMut;
use std::s... | }
_ => {
if new.file_type!= FileType::GitSubmodule {
map.insert(
entry.path,
Action::Update(UpdateAction::new(Some(old), new)),
... | {
let mut map = HashMap::new();
for entry in diff {
let entry = entry?;
match entry.diff_type {
DiffType::LeftOnly(_) => {
map.insert(entry.path, Action::Remove);
}
DiffType::RightOnly(meta) => {
... | identifier_body |
actions.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
use std::collections::hash_map::Entry;
use std::collections::HashMap;
use std::fmt;
use std::ops::Deref;
use std::ops::DerefMut;
use std::s... | let actions = ActionMap::empty().with_sparse_profile_change(
ab_profile.clone(),
ab_profile.clone(),
&old_manifest,
&manifest,
)?;
assert_eq!("", &actions.to_string());
let mut expected_actions = ActionMap::empty();
expected_action... | let old_manifest = make_tree_manifest_from_meta(store.clone(), vec![]);
let manifest = make_tree_manifest_from_meta(store, vec![a, b, c]);
| random_line_split |
actions.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
use std::collections::hash_map::Entry;
use std::collections::HashMap;
use std::fmt;
use std::ops::Deref;
use std::ops::DerefMut;
use std::s... | (from: Option<FileMetadata>, to: FileMetadata) -> Self {
Self { from, to }
}
}
impl IntoIterator for ActionMap {
type Item = (RepoPathBuf, Action);
type IntoIter = <HashMap<RepoPathBuf, Action> as IntoIterator>::IntoIter;
fn into_iter(self) -> Self::IntoIter {
self.map.into_iter()
... | new | identifier_name |
notes.rs | use crate::models::Note;
use crate::uri_helpers::root_uri;
pub fn notes_uri() -> String {
let mut uri = root_uri();
if!uri.ends_with("/") |
uri.push_str("notes");
uri
}
pub fn notes_atom_uri() -> String {
let mut uri = notes_uri();
uri.push_str(".atom");
uri
}
pub fn note_uri(note: &Note) -> String {
let mut uri = notes_uri();
uri.push_str("/");
uri.push_str(¬e.id.to_string());
uri
}
pub fn edit_note_uri(note: &... | {
uri.push_str("/");
} | conditional_block |
notes.rs | use crate::models::Note;
use crate::uri_helpers::root_uri;
pub fn notes_uri() -> String {
let mut uri = root_uri();
if!uri.ends_with("/") {
uri.push_str("/");
}
uri.push_str("notes");
uri
} | }
pub fn note_uri(note: &Note) -> String {
let mut uri = notes_uri();
uri.push_str("/");
uri.push_str(¬e.id.to_string());
uri
}
pub fn edit_note_uri(note: &Note) -> String {
let mut uri = notes_uri();
uri.push_str("/");
uri.push_str(¬e.id.to_string());
uri.push_str("/edit");
... |
pub fn notes_atom_uri() -> String {
let mut uri = notes_uri();
uri.push_str(".atom");
uri | random_line_split |
notes.rs | use crate::models::Note;
use crate::uri_helpers::root_uri;
pub fn notes_uri() -> String {
let mut uri = root_uri();
if!uri.ends_with("/") {
uri.push_str("/");
}
uri.push_str("notes");
uri
}
pub fn notes_atom_uri() -> String {
let mut uri = notes_uri();
uri.push_str(".atom");
u... |
pub fn new_note_uri() -> String {
let mut uri = notes_uri();
uri.push_str("/new");
uri
}
pub fn delete_note_uri(note: &Note) -> String {
let mut uri = notes_uri();
uri.push_str("/");
uri.push_str(¬e.id.to_string());
uri.push_str("/delete");
uri
}
| {
let mut uri = notes_uri();
uri.push_str("/");
uri.push_str(¬e.id.to_string());
uri.push_str("/edit");
uri
} | identifier_body |
notes.rs | use crate::models::Note;
use crate::uri_helpers::root_uri;
pub fn notes_uri() -> String {
let mut uri = root_uri();
if!uri.ends_with("/") {
uri.push_str("/");
}
uri.push_str("notes");
uri
}
pub fn notes_atom_uri() -> String {
let mut uri = notes_uri();
uri.push_str(".atom");
u... | () -> String {
let mut uri = notes_uri();
uri.push_str("/new");
uri
}
pub fn delete_note_uri(note: &Note) -> String {
let mut uri = notes_uri();
uri.push_str("/");
uri.push_str(¬e.id.to_string());
uri.push_str("/delete");
uri
}
| new_note_uri | identifier_name |
decoder.rs | use std::slice;
use std::old_io::MemReader;
use std::default::Default;
use image;
use image::ImageResult;
use image::ImageDecoder;
use color;
use super::vp8::Frame;
use super::vp8::VP8Decoder;
/// A Representation of a Webp Image format decoder.
pub struct WebpDecoder<R> {
r: R,
frame: Frame,
have_fra... | (&mut self, buf: &mut [u8]) -> ImageResult<u32> {
let _ = try!(self.read_metadata());
if self.decoded_rows > self.frame.height as u32 {
return Err(image::ImageError::ImageEnd)
}
let rlen = buf.len();
let slice = &self.frame.ybuf[
self.decoded_rows as us... | read_scanline | identifier_name |
decoder.rs | use std::slice;
use std::old_io::MemReader;
use std::default::Default;
use image;
use image::ImageResult;
use image::ImageDecoder;
use color;
use super::vp8::Frame;
use super::vp8::VP8Decoder;
/// A Representation of a Webp Image format decoder.
pub struct WebpDecoder<R> {
r: R,
frame: Frame,
have_fra... | }
fn read_image(&mut self) -> ImageResult<image::DecodingResult> {
let _ = try!(self.read_metadata());
Ok(image::DecodingResult::U8(self.frame.ybuf.clone()))
}
} | Ok(self.decoded_rows) | random_line_split |
decoder.rs | use std::slice;
use std::old_io::MemReader;
use std::default::Default;
use image;
use image::ImageResult;
use image::ImageDecoder;
use color;
use super::vp8::Frame;
use super::vp8::VP8Decoder;
/// A Representation of a Webp Image format decoder.
pub struct WebpDecoder<R> {
r: R,
frame: Frame,
have_fra... |
fn read_image(&mut self) -> ImageResult<image::DecodingResult> {
let _ = try!(self.read_metadata());
Ok(image::DecodingResult::U8(self.frame.ybuf.clone()))
}
}
| {
let _ = try!(self.read_metadata());
if self.decoded_rows > self.frame.height as u32 {
return Err(image::ImageError::ImageEnd)
}
let rlen = buf.len();
let slice = &self.frame.ybuf[
self.decoded_rows as usize * rlen..
self.decoded_rows as us... | identifier_body |
decoder.rs | use std::slice;
use std::old_io::MemReader;
use std::default::Default;
use image;
use image::ImageResult;
use image::ImageDecoder;
use color;
use super::vp8::Frame;
use super::vp8::VP8Decoder;
/// A Representation of a Webp Image format decoder.
pub struct WebpDecoder<R> {
r: R,
frame: Frame,
have_fra... |
if &*webp!= "WEBP".as_bytes() {
return Err(image::ImageError::FormatError("Invalid WEBP signature.".to_string()))
}
Ok(size)
}
fn read_vp8_header(&mut self) -> ImageResult<()> {
let vp8 = try!(self.r.read_exact(4));
if &*vp8!= "VP8 ".as_bytes() {
... | {
return Err(image::ImageError::FormatError("Invalid RIFF signature.".to_string()))
} | conditional_block |
bug-7183-generics.rs | // run-pass
trait Speak : Sized {
fn say(&self, s:&str) -> String;
fn | (&self) -> String { hello(self) }
}
fn hello<S:Speak>(s:&S) -> String{
s.say("hello")
}
impl Speak for isize {
fn say(&self, s:&str) -> String {
format!("{}: {}", s, *self)
}
}
impl<T: Speak> Speak for Option<T> {
fn say(&self, s:&str) -> String {
match *self {
None => for... | hi | identifier_name |
bug-7183-generics.rs | // run-pass
trait Speak : Sized {
fn say(&self, s:&str) -> String;
fn hi(&self) -> String { hello(self) }
}
fn hello<S:Speak>(s:&S) -> String{
s.say("hello")
}
impl Speak for isize {
fn say(&self, s:&str) -> String {
format!("{}: {}", s, *self)
}
}
impl<T: Speak> Speak for Option<T> {
... |
}
}
}
pub fn main() {
assert_eq!(3.hi(), "hello: 3".to_string());
assert_eq!(Some(Some(3)).hi(),
"something!something!hello: 3".to_string());
assert_eq!(None::<isize>.hi(), "hello - none".to_string());
assert_eq!(Some(None::<isize>).hi(), "something!hello - none".to_string... | { format!("something!{}", x.say(s)) } | conditional_block |
bug-7183-generics.rs | // run-pass
trait Speak : Sized {
fn say(&self, s:&str) -> String;
fn hi(&self) -> String { hello(self) }
}
fn hello<S:Speak>(s:&S) -> String |
impl Speak for isize {
fn say(&self, s:&str) -> String {
format!("{}: {}", s, *self)
}
}
impl<T: Speak> Speak for Option<T> {
fn say(&self, s:&str) -> String {
match *self {
None => format!("{} - none", s),
Some(ref x) => { format!("something!{}", x.say(s)) }
... | {
s.say("hello")
} | identifier_body |
bug-7183-generics.rs | // run-pass
trait Speak : Sized {
fn say(&self, s:&str) -> String;
fn hi(&self) -> String { hello(self) }
}
fn hello<S:Speak>(s:&S) -> String{
s.say("hello")
}
impl Speak for isize {
fn say(&self, s:&str) -> String {
format!("{}: {}", s, *self) | }
impl<T: Speak> Speak for Option<T> {
fn say(&self, s:&str) -> String {
match *self {
None => format!("{} - none", s),
Some(ref x) => { format!("something!{}", x.say(s)) }
}
}
}
pub fn main() {
assert_eq!(3.hi(), "hello: 3".to_string());
assert_eq!(Some(Some(3... | } | random_line_split |
event_loop.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! This module contains the `EventLoop` type, which is the constellation's
//! view of a script thread. When an `... |
}
impl EventLoop {
/// Create a new event loop from the channel to its script thread.
pub fn new(script_chan: IpcSender<ConstellationControlMsg>) -> Rc<EventLoop> {
Rc::new(EventLoop {
script_chan: script_chan,
dont_send_or_sync: PhantomData,
})
}
/// Send a me... | {
let _ = self
.script_chan
.send(ConstellationControlMsg::ExitScriptThread);
} | identifier_body |
event_loop.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! This module contains the `EventLoop` type, which is the constellation's
//! view of a script thread. When an `... | (&self) -> IpcSender<ConstellationControlMsg> {
self.script_chan.clone()
}
}
| sender | identifier_name |
event_loop.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! This module contains the `EventLoop` type, which is the constellation's
//! view of a script thread. When an `... | let _ = self
.script_chan
.send(ConstellationControlMsg::ExitScriptThread);
}
}
impl EventLoop {
/// Create a new event loop from the channel to its script thread.
pub fn new(script_chan: IpcSender<ConstellationControlMsg>) -> Rc<EventLoop> {
Rc::new(EventLoop {
... | random_line_split | |
route.rs | use std::str::FromStr;
use std::collections::HashSet;
use syntax::ast::*;
use syntax::ext::base::{ExtCtxt, Annotatable};
use syntax::codemap::{Span, Spanned, dummy_spanned};
use utils::{span, MetaItemExt, SpanExt, is_valid_ident};
use super::{Function, ParamIter};
use super::keyvalue::KVSpanned;
use super::uri::valid... | uri: uri,
data_param: data,
query_param: query,
format: format,
rank: rank,
annotated_fn: function,
}
}
pub fn path_params<'s, 'a, 'c: 'a>(&'s self,
ecx: &'a ExtCtxt<'c>)
... | RouteParams {
method: method, | random_line_split |
route.rs | use std::str::FromStr;
use std::collections::HashSet;
use syntax::ast::*;
use syntax::ext::base::{ExtCtxt, Annotatable};
use syntax::codemap::{Span, Spanned, dummy_spanned};
use utils::{span, MetaItemExt, SpanExt, is_valid_ident};
use super::{Function, ParamIter};
use super::keyvalue::KVSpanned;
use super::uri::valid... | let (method, attr_params) = match known_method {
Some(method) => (method, meta_items),
None => (parse_method(ecx, &meta_items[0]), &meta_items[1..])
};
if attr_params.len() < 1 {
ecx.struct_span_err(sp, "attribute requires at least a path")
.he... | {
let function = Function::from(annotated).unwrap_or_else(|item_sp| {
ecx.span_err(sp, "this attribute can only be used on functions...");
ecx.span_fatal(item_sp, "...but was applied to the item above.");
});
let meta_items = meta_item.meta_item_list().unwrap_or_else(|| ... | identifier_body |
route.rs | use std::str::FromStr;
use std::collections::HashSet;
use syntax::ast::*;
use syntax::ext::base::{ExtCtxt, Annotatable};
use syntax::codemap::{Span, Spanned, dummy_spanned};
use utils::{span, MetaItemExt, SpanExt, is_valid_ident};
use super::{Function, ParamIter};
use super::keyvalue::KVSpanned;
use super::uri::valid... | {
pub annotated_fn: Function,
pub method: Spanned<Method>,
pub uri: Spanned<URI<'static>>,
pub data_param: Option<KVSpanned<Ident>>,
pub query_param: Option<Spanned<Ident>>,
pub format: Option<KVSpanned<MediaType>>,
pub rank: Option<KVSpanned<isize>>,
}
impl RouteParams {
/// Parses th... | RouteParams | identifier_name |
route.rs | use std::str::FromStr;
use std::collections::HashSet;
use syntax::ast::*;
use syntax::ext::base::{ExtCtxt, Annotatable};
use syntax::codemap::{Span, Spanned, dummy_spanned};
use utils::{span, MetaItemExt, SpanExt, is_valid_ident};
use super::{Function, ParamIter};
use super::keyvalue::KVSpanned;
use super::uri::valid... | else if let Some(s) = meta_item.str_lit() {
return validate_uri(ecx, &s.as_str(), sp);
} else {
ecx.struct_span_err(sp, r#"expected `path = string` or a path string"#)
.help(r#"you can specify the path directly as a string, \
e.g: "/hello/world", or as a key-value pair,... | {
if name != &"path" {
ecx.span_err(sp, "the first key, if any, must be 'path'");
} else if let LitKind::Str(ref s, _) = lit.node {
return validate_uri(ecx, &s.as_str(), lit.span);
} else {
ecx.span_err(lit.span, "`path` value must be a string")
}
... | conditional_block |
eigen.rs | #[cfg(feature = "serde-serialize")]
use serde::{Deserialize, Serialize};
use num_complex::Complex;
use simba::scalar::ComplexField;
use std::cmp;
use std::fmt::Display;
use std::ops::MulAssign;
use crate::allocator::Allocator;
use crate::base::dimension::{Dim, DimDiff, DimSub, Dynamic, U1, U2, U3};
use crate::base::s... | <N: ComplexField, D: Dim>
where DefaultAllocator: Allocator<N, D, D> + Allocator<N, D>
{
pub eigenvectors: MatrixN<N, D>,
pub eigenvalues: VectorN<N, D>,
}
impl<N: ComplexField, D: Dim> Copy for Eigen<N, D>
where
DefaultAllocator: Allocator<N, D, D> + Allocator<N, D>,
MatrixN<N, D>: Copy,
VectorN<N... | Eigen | identifier_name |
eigen.rs | #[cfg(feature = "serde-serialize")]
use serde::{Deserialize, Serialize};
use num_complex::Complex;
use simba::scalar::ComplexField;
use std::cmp;
use std::fmt::Display;
use std::ops::MulAssign;
use crate::allocator::Allocator;
use crate::base::dimension::{Dim, DimDiff, DimSub, Dynamic, U1, U2, U3};
use crate::base::s... | return None;
}
let z = -eigenvalues[(i, j)] / diff;
for k in j + 1..dim {
eigenvalues[(i, k)] -= z * eigenvalues[(j, k)];
}
for k in 0..dim {
eigenvectors[(k, j)] += z * eigenve... | for i in 0..j {
let diff = eigenvalues[(i, i)] - eigenvalues[(j, j)];
if diff.is_zero() && !eigenvalues[(i, j)].is_zero() { | random_line_split |
eigen.rs | #[cfg(feature = "serde-serialize")]
use serde::{Deserialize, Serialize};
use num_complex::Complex;
use simba::scalar::ComplexField;
use std::cmp;
use std::fmt::Display;
use std::ops::MulAssign;
use crate::allocator::Allocator;
use crate::base::dimension::{Dim, DimDiff, DimSub, Dynamic, U1, U2, U3};
use crate::base::s... |
let z = -eigenvalues[(i, j)] / diff;
for k in j + 1..dim {
eigenvalues[(i, k)] -= z * eigenvalues[(j, k)];
}
for k in 0..dim {
eigenvectors[(k, j)] += z * eigenvectors[(k, i)];
}
}
... | {
return None;
} | conditional_block |
eigen.rs | #[cfg(feature = "serde-serialize")]
use serde::{Deserialize, Serialize};
use num_complex::Complex;
use simba::scalar::ComplexField;
use std::cmp;
use std::fmt::Display;
use std::ops::MulAssign;
use crate::allocator::Allocator;
use crate::base::dimension::{Dim, DimDiff, DimSub, Dynamic, U1, U2, U3};
use crate::base::s... | let diff = eigenvalues[(i, i)] - eigenvalues[(j, j)];
if diff.is_zero() &&!eigenvalues[(i, j)].is_zero() {
return None;
}
let z = -eigenvalues[(i, j)] / diff;
for k in j + 1..dim {
eigenvalues[(i, ... | {
assert!(
m.is_square(),
"Unable to compute the eigendecomposition of a non-square matrix."
);
let dim = m.nrows();
let (mut eigenvectors, mut eigenvalues) = Schur::new(m, 0).unwrap().unpack();
println!("Schur eigenvalues: {}", eigenvalues);
//... | identifier_body |
bug_char.rs | #include "shared.rsh"
char rand_sc1_0, rand_sc1_1;
char2 rand_sc2_0, rand_sc2_1;
char min_rand_sc1_sc1;
char2 min_rand_sc2_sc2;
static bool test_bug_char() {
bool failed = false;
rsDebug("rand_sc2_0.x: ", rand_sc2_0.x);
rsDebug("rand_sc2_0.y: ", rand_sc2_0.y);
rsDebug("rand_sc2_1.x: ", rand_sc2_1.x)... |
rsDebug("broken", 'y');
temp_sc2 = min( rand_sc2_0, rand_sc2_1 );
if (temp_sc2.x!= min_rand_sc2_sc2.x
|| temp_sc2.y!= min_rand_sc2_sc2.y) {
failed = true;
}
return failed;
}
void bug_char_test() {
bool failed = false;
failed |= test_bug_char();
if (failed) {
... | {
rsDebug("temp_sc1", temp_sc1);
failed = true;
} | conditional_block |
bug_char.rs | #include "shared.rsh"
char rand_sc1_0, rand_sc1_1;
char2 rand_sc2_0, rand_sc2_1;
char min_rand_sc1_sc1;
char2 min_rand_sc2_sc2;
static bool test_bug_char() {
bool failed = false;
rsDebug("rand_sc2_0.x: ", rand_sc2_0.x);
rsDebug("rand_sc2_0.y: ", rand_sc2_0.y);
rsDebug("rand_sc2_1.x: ", rand_sc2_1.x)... | if (failed) {
rsSendToClientBlocking(RS_MSG_TEST_FAILED);
}
else {
rsSendToClientBlocking(RS_MSG_TEST_PASSED);
}
} | void bug_char_test() {
bool failed = false;
failed |= test_bug_char();
| random_line_split |
misc.rs | // Copyright 2013-2015, The Gtk-rs Project Developers.
// See the COPYRIGHT file at the top-level directory of this distribution.
// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>
use libc::{c_float, c_int};
use cast::GTK_MISC;
use ffi;
pub trait MiscTrait: ::WidgetTrait ... | (&self, x_align: f32, y_align: f32) -> () {
unsafe {
ffi::gtk_misc_set_alignment(GTK_MISC(self.unwrap_widget()), x_align as c_float, y_align as c_float);
}
}
fn set_padding(&self, x_pad: i32, y_pad: i32) -> () {
unsafe {
ffi::gtk_misc_set_padding(GTK_MISC(self.un... | set_alignment | identifier_name |
misc.rs | // Copyright 2013-2015, The Gtk-rs Project Developers.
// See the COPYRIGHT file at the top-level directory of this distribution.
// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>
use libc::{c_float, c_int};
use cast::GTK_MISC;
use ffi;
pub trait MiscTrait: ::WidgetTrait ... | (x as i32, y as i32)
}
} | random_line_split | |
misc.rs | // Copyright 2013-2015, The Gtk-rs Project Developers.
// See the COPYRIGHT file at the top-level directory of this distribution.
// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>
use libc::{c_float, c_int};
use cast::GTK_MISC;
use ffi;
pub trait MiscTrait: ::WidgetTrait ... |
fn get_alignment(&self) -> (f32, f32) {
let mut x: c_float = 0.;
let mut y: c_float = 0.;
unsafe {
ffi::gtk_misc_get_alignment(GTK_MISC(self.unwrap_widget()), &mut x, &mut y);
}
(x as f32, y as f32)
}
fn get_padding(&self) -> (i32, i32) {
let mu... | {
unsafe {
ffi::gtk_misc_set_padding(GTK_MISC(self.unwrap_widget()), x_pad as c_int, y_pad as c_int);
}
} | identifier_body |
rem.rs | #![feature(core, core_simd)]
extern crate core;
#[cfg(test)]
mod tests {
use core::simd::u16x8;
// #[simd]
// #[derive(Copy, Clone, Debug)]
// #[repr(C)]
// pub struct u16x8(pub u16, pub u16, pub u16, pub u16,
// pub u16, pub u16, pub u16, pub u16);
#[test]
fn | () {
let x: u16x8 = u16x8(
0, 1, 2, 3, 4, 5, 6, 7
);
let y: u16x8 = u16x8(
2, 2, 2, 2, 2, 2, 2, 2
);
let z: u16x8 = x % y;
let result: String = format!("{:?}", z);
assert_eq!(result, "u16x8(\
0, 1, 0, 1, 0, 1, 0, 1\
)".to_string());
}
}
| rem_test1 | identifier_name |
rem.rs | #![feature(core, core_simd)]
extern crate core;
#[cfg(test)]
mod tests {
use core::simd::u16x8;
// #[simd]
// #[derive(Copy, Clone, Debug)]
// #[repr(C)]
// pub struct u16x8(pub u16, pub u16, pub u16, pub u16,
// pub u16, pub u16, pub u16, pub u16);
#[test]
fn rem_tes... |
}
| {
let x: u16x8 = u16x8(
0, 1, 2, 3, 4, 5, 6, 7
);
let y: u16x8 = u16x8(
2, 2, 2, 2, 2, 2, 2, 2
);
let z: u16x8 = x % y;
let result: String = format!("{:?}", z);
assert_eq!(result, "u16x8(\
0, 1, 0, 1, 0, 1, 0, 1\
)".to_string());
} | identifier_body |
rem.rs | #![feature(core, core_simd)]
extern crate core;
#[cfg(test)]
mod tests {
use core::simd::u16x8;
// #[simd]
// #[derive(Copy, Clone, Debug)]
// #[repr(C)]
// pub struct u16x8(pub u16, pub u16, pub u16, pub u16,
// pub u16, pub u16, pub u16, pub u16);
#[test]
fn rem_tes... | )".to_string());
}
} | let z: u16x8 = x % y;
let result: String = format!("{:?}", z);
assert_eq!(result, "u16x8(\
0, 1, 0, 1, 0, 1, 0, 1\ | random_line_split |
show.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 ... |
// We want to make sure we have the expn_id set so that we can use unstable methods
let span = Span { expn_id: cx.backtrace(),.. span };
let name = cx.expr_lit(span, ast::Lit_::LitStr(token::get_ident(name),
ast::StrStyle::CookedStr));
let mut expr = s... | }
}; | random_line_split |
show.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 ... | combine_substructure: combine_substructure(Box::new(|a, b, c| {
show_substructure(a, b, c)
}))
}
],
associated_types: Vec::new(),
};
trait_def.expand(cx, mitem, item, push)
}
/// We use the debug builders to do the heavy lifting h... | {
// &mut ::std::fmt::Formatter
let fmtr = Ptr(Box::new(Literal(path_std!(cx, core::fmt::Formatter))),
Borrowed(None, ast::MutMutable));
let trait_def = TraitDef {
span: span,
attributes: Vec::new(),
path: path_std!(cx, core::fmt::Debug),
additional_bounds... | identifier_body |
show.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 ... | (cx: &mut ExtCtxt, span: Span,
substr: &Substructure) -> P<Expr> {
// build fmt.debug_struct(<name>).field(<fieldname>, &<fieldval>)....build()
// or fmt.debug_tuple(<name>).field(&<fieldval>)....build()
// based on the "shape".
let name = match *substr.fields {
Struct(_) =>... | show_substructure | identifier_name |
context.rs | //-
// Copyright (c) 2016, 2017, 2021, Jason Lingle
//
// This file is part of Ensync.
//
// Ensync 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) ... |
}
pub trait ContextExt {
type Dir;
}
impl<CLI: Replica, ANC: Replica, SRV: Replica> ContextExt
for Context<CLI, ANC, SRV>
{
type Dir = DirContext<CLI::Directory, ANC::Directory, SRV::Directory>;
}
/// Directory-specific context information for a single replica.
pub struct SingleDirContext<T> {
/// T... | {
self.work.run(|task| task.invoke(self));
} | identifier_body |
context.rs | //-
// Copyright (c) 2016, 2017, 2021, Jason Lingle
//
// This file is part of Ensync.
//
// Ensync 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) ... | <F: Send>(Mutex<Option<F>>);
pub trait TaskT<T>: Send {
fn invoke(&self, t: &T);
}
impl<T, F: FnOnce(&T) + Send> TaskT<T> for TaskContainer<F> {
fn invoke(&self, t: &T) {
self.0.lock().unwrap().take().unwrap()(t)
}
}
pub type Task<T> = Box<dyn TaskT<T>>;
pub fn task<T, F: FnOnce(&T) + Send +'static>... | TaskContainer | identifier_name |
context.rs | //-
// Copyright (c) 2016, 2017, 2021, Jason Lingle
//
// This file is part of Ensync.
//
// Ensync 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) ... |
impl<T: Ord> Ord for Reversed<T> {
fn cmp(&self, other: &Self) -> Ordering {
other.0.cmp(&self.0)
}
} | } | random_line_split |
unwind-misc-1.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 _count = box(GC) 0u;
let mut map = collections::HashMap::new();
let mut arr = Vec::new();
for _i in range(0u, 10u) {
arr.push(box(GC) "key stuff".to_string());
map.insert(arr.clone(),
arr.clone().append([box(GC) "value stuff".to_string()]));
if arr.len() ... | identifier_body | |
unwind-misc-1.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 ... | fail!();
}
}
} | random_line_split | |
unwind-misc-1.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 _count = box(GC) 0u;
let mut map = collections::HashMap::new();
let mut arr = Vec::new();
for _i in range(0u, 10u) {
arr.push(box(GC) "key stuff".to_string());
map.insert(arr.clone(),
arr.clone().append([box(GC) "value stuff".to_string()]));
if arr.len... | main | identifier_name |
unwind-misc-1.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 ... |
}
}
| {
fail!();
} | conditional_block |
fact.rs | // @author: Constantine Apostolou
// @description:
// Testing how recursive implementation of a function
// that computes the factorial behaves in Rust.
// @license: GNU GPL v3
// We add the following line to be able to "use" everything
// in a library, since the "lib::*" feature is experimental.
#![feature(glob... |
// Computes the factorial of a manner in a
// tail-recursive manner. From the parameters:
// 'n' is the number of which we want to find the factorial.
// 'a' is initialy 1 and will carry the result of the
// computation of the factorial.
fn facttail(n: u64, a: u64) -> u64 {
if n == 1 {
return a;
}... | {
if n < 2 {
1
} else {
n * fact(n - 1)
}
} | identifier_body |
fact.rs | // @author: Constantine Apostolou
// @description:
// Testing how recursive implementation of a function
// that computes the factorial behaves in Rust.
// @license: GNU GPL v3
// We add the following line to be able to "use" everything
// in a library, since the "lib::*" feature is experimental.
#![feature(glob... | else {
n * fact(n - 1)
}
}
// Computes the factorial of a manner in a
// tail-recursive manner. From the parameters:
// 'n' is the number of which we want to find the factorial.
// 'a' is initialy 1 and will carry the result of the
// computation of the factorial.
fn facttail(n: u64, a: u64) -> u64 {
... | {
1
} | conditional_block |
fact.rs | // @author: Constantine Apostolou
// @description:
// Testing how recursive implementation of a function
// that computes the factorial behaves in Rust.
// @license: GNU GPL v3
// We add the following line to be able to "use" everything
// in a library, since the "lib::*" feature is experimental.
#![feature(glob... | (n: u64, a: u64) -> u64 {
if n == 1 {
return a;
}
else if n == 0 {
return 1;
}
else {
if n < 0 {
return 0;
}
return facttail(n - 1, n * a);
}
}
// Main entry to the program:
fn main() {
// Store the parameters that were passed through the... | facttail | identifier_name |
fact.rs | // @author: Constantine Apostolou
// @description:
// Testing how recursive implementation of a function
// that computes the factorial behaves in Rust.
// @license: GNU GPL v3
// We add the following line to be able to "use" everything
// in a library, since the "lib::*" feature is experimental.
#![feature(glob... | println!("\tThis program computes the factorial of a given number.");
println!("\t[number] must be a positive number.");
unsafe {
exit(1 as c_int);
}
}
// This step does not check if we have a character/string instead
// of a number.
// Save the number that... | if args.len() < 2 {
println!("Usage: fact [number]"); | random_line_split |
int.rs | // This file is part of Mooneye GB.
// Copyright (C) 2014-2020 Joonas Javanainen <joonas.javanainen@gmail.com>
//
// Mooneye GB 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... | {
/// Isolates the rightmost 1-bit leaving all other bits as 0
/// e.g. 1010 1000 -> 0000 1000
///
/// Equivalent to Intel BMI1 instruction BLSI
#[inline(always)]
fn isolate_rightmost_one(self) -> Self {
let x = self;
// Unsigned negation: -x ==!x + 1
let minus_x = (!x).wrapping_add(&Self::one()... | }
impl<T> IntExt for T
where
T: PrimInt + WrappingAdd + WrappingSub, | random_line_split |
int.rs | // This file is part of Mooneye GB.
// Copyright (C) 2014-2020 Joonas Javanainen <joonas.javanainen@gmail.com>
//
// Mooneye GB 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... | (bit: usize, a: Self, b: Self) -> bool {
// Create a mask that includes the specified bit and 1-bits on the right side
// e.g. for u8:
// bit=0 -> 0000 0001
// bit=3 -> 0000 1111
// bit=6 -> 0111 1111
let mask = (Self::one() << bit).activate_rightmost_zeros();
(a & mask) + (b & mask) >... | test_add_carry_bit | identifier_name |
int.rs | // This file is part of Mooneye GB.
// Copyright (C) 2014-2020 Joonas Javanainen <joonas.javanainen@gmail.com>
//
// Mooneye GB 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... |
}
#[cfg(test)]
#[test]
fn test_u8_isolate_rightmost_one() {
fn prop(x: u8) -> bool {
test_isolate_rightmost_one(x)
}
quickcheck(prop as fn(u8) -> bool);
}
#[cfg(test)]
#[test]
fn test_u16_isolate_rightmost_one() {
fn prop(x: u16) -> bool {
test_isolate_rightmost_one(x)
}
quickcheck(prop as fn(u16... | {
let mut value = x;
let mut expected = T::one();
while !value.bit_bool(0) {
value = value >> 1;
expected = expected << 1;
}
y == expected
} | conditional_block |
int.rs | // This file is part of Mooneye GB.
// Copyright (C) 2014-2020 Joonas Javanainen <joonas.javanainen@gmail.com>
//
// Mooneye GB 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... |
#[cfg(test)]
#[test]
fn test_u16_isolate_rightmost_one() {
fn prop(x: u16) -> bool {
test_isolate_rightmost_one(x)
}
quickcheck(prop as fn(u16) -> bool);
}
| {
fn prop(x: u8) -> bool {
test_isolate_rightmost_one(x)
}
quickcheck(prop as fn(u8) -> bool);
} | identifier_body |
poly.rs | use std::iter::Iterator;
use super::{Circ, Line, Rect, Shape, Vector2};
pub struct Poly {
pub pos: Vector2,
pub rotation: f32,
pub scale: f32,
pub origin: Vector2,
pub points: Vec<Vector2>,
}
impl Poly {
pub fn new(pos: Vector2, points: Vec<Vector2>) -> Poly {
Poly {
pos: p... | fn overlaps<T: Shape>(&self, shape: &T) -> bool {
if self.contains(shape.get_position()) {
return true;
}
for i in 0..(self.points.len() + 1) {
let one = self.vertex(i % self.points.len());
let two = self.vertex((i + self.points.len() - 1) % self.points.le... | fn overlaps_poly(&self, poly: &Poly) -> bool {
self.overlaps(poly)
} | random_line_split |
poly.rs | use std::iter::Iterator;
use super::{Circ, Line, Rect, Shape, Vector2};
pub struct Poly {
pub pos: Vector2,
pub rotation: f32,
pub scale: f32,
pub origin: Vector2,
pub points: Vec<Vector2>,
}
impl Poly {
pub fn new(pos: Vector2, points: Vec<Vector2>) -> Poly {
Poly {
pos: p... | (rect: Rect, origin: Vector2) -> Poly {
Poly {
pos: Vector2::new(rect.x, rect.y),
origin: origin,
rotation: 0f32,
scale: 1f32,
points: vec![Vector2::new(0f32, 0f32),
Vector2::new(0f32, rect.height),
Vec... | from_rect | identifier_name |
poly.rs | use std::iter::Iterator;
use super::{Circ, Line, Rect, Shape, Vector2};
pub struct Poly {
pub pos: Vector2,
pub rotation: f32,
pub scale: f32,
pub origin: Vector2,
pub points: Vec<Vector2>,
}
impl Poly {
pub fn new(pos: Vector2, points: Vec<Vector2>) -> Poly {
Poly {
pos: p... |
}
| {
let get_x = |vector: &Vector2| vector.x;
let get_y = |vector: &Vector2| vector.y;
let minimum = |a, b| { if b < a { b } else { a } };
let maximum = |a, b| { if b > a { b } else { a } };
let x = self.points[0].x;
let y = self.points[0].y;
let min_x = self.points.... | identifier_body |
poly.rs | use std::iter::Iterator;
use super::{Circ, Line, Rect, Shape, Vector2};
pub struct Poly {
pub pos: Vector2,
pub rotation: f32,
pub scale: f32,
pub origin: Vector2,
pub points: Vec<Vector2>,
}
impl Poly {
pub fn new(pos: Vector2, points: Vec<Vector2>) -> Poly {
Poly {
pos: p... |
for i in 0..(self.points.len() + 1) {
let one = self.vertex(i % self.points.len());
let two = self.vertex((i + self.points.len() - 1) % self.points.len());
let face = Line::new(one, two);
println!("{}:{}, {}:{}", one.x, one.y, two.x, two.y);
if shape.... | {
return true;
} | conditional_block |
build.rs | #![allow(unused_variables)]
// extern crate bindgen;
extern crate make_cmd;
use make_cmd::make;
use std::env;
use std::path::Path;
use std::process::Command;
const LIBSIXEL_DIR: &str = "libsixel";
fn main() | let pixbuf = has_feature("pixbuf");
let png = has_feature("png");
let gd = has_feature("gd");
let python_interface = has_feature("python_interface");
let sixel_dir = Path::new(LIBSIXEL_DIR);
{
let mut cmd = Command::new("./configure");
cmd.current_dir(sixel_dir)
.a... | {
let testing_build = false;
let out_dir = env::var("OUT_DIR").unwrap();
let out_dir = Path::new(&out_dir);
println!("cargo:rustc-link-lib=dylib=sixel");
// println!("cargo:rustc-link-lib=static=sixel");
println!("cargo:rustc-link-search=native={}", out_dir.join("lib").display());
if t... | identifier_body |
build.rs | #![allow(unused_variables)]
// extern crate bindgen;
extern crate make_cmd;
use make_cmd::make;
use std::env;
use std::path::Path;
use std::process::Command;
const LIBSIXEL_DIR: &str = "libsixel";
fn | () {
let testing_build = false;
let out_dir = env::var("OUT_DIR").unwrap();
let out_dir = Path::new(&out_dir);
println!("cargo:rustc-link-lib=dylib=sixel");
// println!("cargo:rustc-link-lib=static=sixel");
println!("cargo:rustc-link-search=native={}", out_dir.join("lib").display());
i... | main | identifier_name |
build.rs | #![allow(unused_variables)]
// extern crate bindgen;
extern crate make_cmd;
use make_cmd::make;
use std::env;
use std::path::Path;
use std::process::Command;
const LIBSIXEL_DIR: &str = "libsixel";
fn main() {
let testing_build = false;
let out_dir = env::var("OUT_DIR").unwrap();
let out_dir = Path:... |
if gd {
cmd.arg("--with-gd");
}
if pixbuf {
cmd.arg("--with-gdk-pixbuf");
}
if jpeg {
cmd.arg("--with-jpeg");
}
if png {
cmd.arg("--with-png");
}
if!python_interface {
cmd.arg("--without-... | {
cmd.arg("--with-libcurl");
} | conditional_block |
build.rs | #![allow(unused_variables)]
// extern crate bindgen;
extern crate make_cmd;
use make_cmd::make;
use std::env;
use std::path::Path;
use std::process::Command;
const LIBSIXEL_DIR: &str = "libsixel";
fn main() {
let testing_build = false;
let out_dir = env::var("OUT_DIR").unwrap();
let out_dir = Path:... |
make()
.arg("install")
.current_dir(sixel_dir)
.status().expect("Failed to execute make");
}
// generate_bindings(out_dir);
}
// fn generate_bindings(out_dir: &Path) {
// let bindings = bindgen::Builder::default()
// .no_unstable_rust()
// ... | if !python_interface {
cmd.arg("--without-python");
}
cmd.status().expect("Failed to execute ./configure"); | random_line_split |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.