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 |
|---|---|---|---|---|
option_map_unit_fn_unfixable.rs | #![warn(clippy::option_map_unit_fn)]
#![allow(unused)]
fn do_nothing<T>(_: T) {}
fn diverge<T>(_: T) ->! |
fn plus_one(value: usize) -> usize {
value + 1
}
#[rustfmt::skip]
fn option_map_unit_fn() {
x.field.map(|value| { do_nothing(value); do_nothing(value) });
x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value) });
// Suggestion for the let block should be `{... }` as it's too diff... | {
panic!()
} | identifier_body |
option_map_unit_fn_unfixable.rs | #![warn(clippy::option_map_unit_fn)]
#![allow(unused)]
fn do_nothing<T>(_: T) {}
fn diverge<T>(_: T) ->! {
panic!()
}
fn plus_one(value: usize) -> usize {
value + 1
}
#[rustfmt::skip]
fn option_map_unit_fn() {
x.field.map(|value| { do_nothing(value); do_nothing(value) });
x.field.map(|value| if va... | );
// Suggestion for the let block should be `{... }` as it's too difficult to build a
// proper suggestion for these cases
x.field.map(|value| {
do_nothing(value);
do_nothing(value)
});
x.field.map(|value| { do_nothing(value); do_nothing(value); });
// The following should sug... | { do_nothing(value); do_nothing(value) } | conditional_block |
problem4.rs | use std::cmp;
pub fn solution() {
println!("{:?}", number_vec(123));
let mut new_max = 0;
for a in 100..1000 {
for b in a..1000 { | println!("{}", new_max);
}
fn is_palindrome<A: PartialEq>(v: Vec<A>) -> bool {
for i in 0..v.len() {
if v[i]!= v[v.len() - i - 1] {
return false;
}
}
true
}
fn number_vec(n: u64) -> Vec<u64> {
let mut output = Vec::new();
let mut x = n;
while x!= 0 {
out... | if is_palindrome(number_vec(a * b)) {
new_max = cmp::max(new_max, a * b);
}
}
} | random_line_split |
problem4.rs | use std::cmp;
pub fn solution() {
println!("{:?}", number_vec(123));
let mut new_max = 0;
for a in 100..1000 {
for b in a..1000 {
if is_palindrome(number_vec(a * b)) {
new_max = cmp::max(new_max, a * b);
}
}
}
println!("{}", new_max);
}
fn is... |
fn number_vec(n: u64) -> Vec<u64> {
let mut output = Vec::new();
let mut x = n;
while x!= 0 {
output.push(x % 10);
x /= 10;
}
output
}
| {
for i in 0..v.len() {
if v[i] != v[v.len() - i - 1] {
return false;
}
}
true
} | identifier_body |
problem4.rs | use std::cmp;
pub fn solution() {
println!("{:?}", number_vec(123));
let mut new_max = 0;
for a in 100..1000 {
for b in a..1000 {
if is_palindrome(number_vec(a * b)) {
new_max = cmp::max(new_max, a * b);
}
}
}
println!("{}", new_max);
}
fn is... |
}
true
}
fn number_vec(n: u64) -> Vec<u64> {
let mut output = Vec::new();
let mut x = n;
while x!= 0 {
output.push(x % 10);
x /= 10;
}
output
}
| {
return false;
} | conditional_block |
problem4.rs | use std::cmp;
pub fn | () {
println!("{:?}", number_vec(123));
let mut new_max = 0;
for a in 100..1000 {
for b in a..1000 {
if is_palindrome(number_vec(a * b)) {
new_max = cmp::max(new_max, a * b);
}
}
}
println!("{}", new_max);
}
fn is_palindrome<A: PartialEq>(v: V... | solution | identifier_name |
lib.rs | // Copyright 2012-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-MI... | pub mod graph;
pub mod intrinsicck;
pub mod infer;
pub mod lang_items;
pub mod liveness;
pub mod mem_categorization;
pub mod pat_util;
pub mod privacy;
pub mod reachable;
pub mod region;
pub mod recursion_limit;
pub mod resolve_lifetime;
pub mod stability;
pub mod... | pub mod expr_use_visitor;
pub mod fast_reject; | random_line_split |
sky.rs | use std::f32::consts::PI;
use cgmath;
use cgmath::prelude::*;
use rand::Rng;
use three::{self, Object};
use COLOR_WHITE;
pub struct Sky {
pub group: three::Group,
}
impl Sky {
fn make_cloud<R: Rng>(
rng: &mut R,
factory: &mut three::Factory,
) -> three::Group {
let group = facto... | );
group.add(&m);
}
group
}
pub fn new<R: Rng>(
rng: &mut R,
factory: &mut three::Factory,
) -> Self {
let group = factory.group();
let num = 20i32;
let step_angle = PI * 2.0 / num as f32;
for i in 0.. num {
... | q,
rng.gen_range(0.1, 1.0), | random_line_split |
sky.rs | use std::f32::consts::PI;
use cgmath;
use cgmath::prelude::*;
use rand::Rng;
use three::{self, Object};
use COLOR_WHITE;
pub struct Sky {
pub group: three::Group,
}
impl Sky {
fn make_cloud<R: Rng>(
rng: &mut R,
factory: &mut three::Factory,
) -> three::Group {
let group = facto... | <R: Rng>(
rng: &mut R,
factory: &mut three::Factory,
) -> Self {
let group = factory.group();
let num = 20i32;
let step_angle = PI * 2.0 / num as f32;
for i in 0.. num {
let cloud = Self::make_cloud(rng, factory);
let angle = cgmath::Rad(i as f... | new | identifier_name |
sky.rs | use std::f32::consts::PI;
use cgmath;
use cgmath::prelude::*;
use rand::Rng;
use three::{self, Object};
use COLOR_WHITE;
pub struct Sky {
pub group: three::Group,
}
impl Sky {
fn make_cloud<R: Rng>(
rng: &mut R,
factory: &mut three::Factory,
) -> three::Group | );
group.add(&m);
}
group
}
pub fn new<R: Rng>(
rng: &mut R,
factory: &mut three::Factory,
) -> Self {
let group = factory.group();
let num = 20i32;
let step_angle = PI * 2.0 / num as f32;
for i in 0.. num {
... | {
let group = factory.group();
let geo = three::Geometry::cuboid(20.0, 20.0, 20.0);
let material = three::material::Lambert {
color: COLOR_WHITE,
flat: true,
};
let template = factory.mesh(geo, material.clone());
for i in 0i32 .. rng.gen_range(3, 6... | identifier_body |
loader.rs | use Bv1 and Bv2, then it
//! would look something like:
//!
//! ```ignore
//! extern crate b1;
//! extern crate b2;
//!
//! fn main() {}
//! ```
//!
//! and the compiler would be invoked as:
//!
//! ```text
//! rustc a.rs --extern b1=path/to/libb1.rlib --extern b2=path/to/libb2.rlib
//! ```
//!
//! In this scenario th... | (&self) -> (String, String) {
let t = &self.sess.target.target;
(t.options.dll_prefix.clone(), t.options.dll_suffix.clone())
}
fn find_commandline_library(&mut self) -> Option<Library> {
let locs = match self.sess.opts.externs.get(self.crate_name) {
Some(s) => s,
... | dylibname | identifier_name |
loader.rs | (file.slice(dylib_prefix.len(), file.len() - dypair.1.len()),
false)
} else {
return FileDoesntMatch
};
info!("lib candidate: {}", path.display());
let hash_str = hash.to_string();
let slot = candidates.entry(hash_str... | {
if is_osx {
"__note.rustc"
} else {
".note.rustc"
}
} | identifier_body | |
loader.rs | to use Bv1 and Bv2, then it
//! would look something like:
//!
//! ```ignore
//! extern crate b1;
//! extern crate b2;
//!
//! fn main() {}
//! ```
//!
//! and the compiler would be invoked as:
//!
//! ```text
//! rustc a.rs --extern b1=path/to/libb1.rlib --extern b2=path/to/libb2.rlib
//! ```
//!
//! In this scenario... | use std::io;
use std::ptr;
use std::slice;
use std::time::Duration;
use flate;
pub struct CrateMismatch {
path: Path,
got: String,
}
pub struct Context<'a> {
pub sess: &'a Session,
pub span: Span,
pub ident: &'a str,
pub crate_name: &'a str,
pub hash: Option<&'a Svh>,
pub triple: &'a ... | use std::collections::{HashMap, HashSet};
use std::io::fs::PathExtensions; | random_line_split |
mount.rs | use libc::{c_ulong, c_int};
use libc;
use {Result, NixPath};
use errno::Errno;
libc_bitflags!(
pub struct MsFlags: c_ulong {
/// Mount read-only
MS_RDONLY;
/// Ignore suid and sgid bits
MS_NOSUID;
/// Disallow access to device special files
MS_NODEV;
/// Disa... | {
let res = try!(target.with_nix_path(|cstr| {
unsafe { libc::umount2(cstr.as_ptr(), flags.bits) }
}));
Errno::result(res).map(drop)
} | identifier_body | |
mount.rs | use libc::{c_ulong, c_int};
use libc;
use {Result, NixPath};
use errno::Errno;
libc_bitflags!(
pub struct MsFlags: c_ulong {
/// Mount read-only
MS_RDONLY;
/// Ignore suid and sgid bits
MS_NOSUID;
/// Disallow access to device special files
MS_NODEV;
/// Disa... | MS_MGC_MSK;
}
);
libc_bitflags!(
pub struct MntFlags: c_int {
MNT_FORCE;
MNT_DETACH;
MNT_EXPIRE;
}
);
pub fn mount<P1:?Sized + NixPath, P2:?Sized + NixPath, P3:?Sized + NixPath, P4:?Sized + NixPath>(
source: Option<&P1>,
target: &P2,
fstype: Option<&... | random_line_split | |
mount.rs | use libc::{c_ulong, c_int};
use libc;
use {Result, NixPath};
use errno::Errno;
libc_bitflags!(
pub struct MsFlags: c_ulong {
/// Mount read-only
MS_RDONLY;
/// Ignore suid and sgid bits
MS_NOSUID;
/// Disallow access to device special files
MS_NODEV;
/// Disa... | <P1:?Sized + NixPath, P2:?Sized + NixPath, P3:?Sized + NixPath, P4:?Sized + NixPath>(
source: Option<&P1>,
target: &P2,
fstype: Option<&P3>,
flags: MsFlags,
data: Option<&P4>) -> Result<()> {
use libc;
let res = try!(try!(try!(try!(
source.with_nix_path(|source| ... | mount | identifier_name |
lib.rs | //! The purpose of this library is to provide an OpenGL context on as many
//! platforms as possible.
//!
//! # Building a window
//!
//! There are two ways to create a window:
//!
//! - Calling `Window::new()`.
//! - Calling `let builder = WindowBuilder::new()` then `builder.build()`.
//!
//! The first way is the s... |
}
/// All APIs related to OpenGL that you can possibly get while using glutin.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Api {
/// The classical OpenGL. Available on Windows, Linux, OS/X.
OpenGl,
/// OpenGL embedded system. Available on Linux, Android.
OpenGlEs,
/// OpenGL for the web.... | {
self.to_string()
} | identifier_body |
lib.rs | //! The purpose of this library is to provide an OpenGL context on as many
//! platforms as possible.
//!
//! # Building a window
//!
//! There are two ways to create a window:
//!
//! - Calling `Window::new()`.
//! - Calling `let builder = WindowBuilder::new()` then `builder.build()`.
//!
//! The first way is the s... |
/// The minimum dimensions a window can be, If this is `None`, the window will have no minimum dimensions (aside from reserved).
///
/// The default is `None`.
pub min_dimensions: Option<(u32, u32)>,
/// The maximum dimensions a window can be, If this is `None`, the maximum will have no maximum or... | pub dimensions: Option<(u32, u32)>, | random_line_split |
lib.rs | //! The purpose of this library is to provide an OpenGL context on as many
//! platforms as possible.
//!
//! # Building a window
//!
//! There are two ways to create a window:
//!
//! - Calling `Window::new()`.
//! - Calling `let builder = WindowBuilder::new()` then `builder.build()`.
//!
//! The first way is the s... | {
/// Not everything is checked. Your application can crash if you do something wrong with your
/// shaders.
NotRobust,
/// The driver doesn't check anything. This option is very dangerous. Please know what you're
/// doing before using it. See the `GL_KHR_no_error` extension.
///
/// Sinc... | Robustness | identifier_name |
lib.rs | // Copyright 2013-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... |
#[cfg(windows)]
/// Return a Terminal wrapping stdout, or None if a terminal couldn't be
/// opened.
pub fn stdout() -> Option<Box<Terminal<WriterWrapper> + Send>> {
let ti = TerminfoTerminal::new(WriterWrapper {
wrapped: box std::io::stdout(),
});
match ti {
Some(t) => Some(t),
N... | {
TerminfoTerminal::new(WriterWrapper {
wrapped: box std::io::stdout(),
})
} | identifier_body |
lib.rs | // Copyright 2013-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... | () -> Option<Box<Terminal<WriterWrapper> + Send>> {
TerminfoTerminal::new(WriterWrapper {
wrapped: box std::io::stderr(),
})
}
#[cfg(windows)]
/// Return a Terminal wrapping stderr, or None if a terminal couldn't be
/// opened.
pub fn stderr() -> Option<Box<Terminal<WriterWrapper> + Send>> {
let ti... | stderr | identifier_name |
lib.rs | // Copyright 2013-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... | Italic(bool),
/// Underline mode
Underline(bool),
/// Blink mode
Blink,
/// Standout mode. Often implemented as Reverse, sometimes coupled with Bold
Standout(bool),
/// Reverse mode, inverts the foreground and background colors
Reverse,
///... | /// Bold (or possibly bright) mode
Bold,
/// Dim mode, also called faint or half-bright. Often not supported
Dim,
/// Italics mode. Often not supported | random_line_split |
sim.rs | use col::CappedList;
use num::traits::Float;
use std::cmp::Ordering;
use strsim;
/// Gets the best jaro match for the input word.
pub fn best_match<'a>(dict: &'a [String], target: &'a str) -> Option<&'a str> {
let (_, word) = dict.iter()
.map(|word| (strsim::jaro(word, target), word))
.fold((0.0, "")... | <'a>(dict: &'a [String], target: &'a str) -> Option<&'a str> {
let (_, word) = dict.iter()
.map(|word| (strsim::levenshtein(word, target), word))
.fold((usize::max_value(), ""), |(ar, aw), (br, bw)| if br < ar { (br, bw) } else { (ar, aw) });
if word!= "" { Some(&word) } else { None }
}
/// Get... | best_levenshtein_match | identifier_name |
sim.rs | use col::CappedList;
use num::traits::Float;
use std::cmp::Ordering;
use strsim;
/// Gets the best jaro match for the input word.
pub fn best_match<'a>(dict: &'a [String], target: &'a str) -> Option<&'a str> {
let (_, word) = dict.iter()
.map(|word| (strsim::jaro(word, target), word))
.fold((0.0, "")... | else { (ar, aw) });
if word!= "" { Some(&word) } else { None }
}
| { (br, bw) } | conditional_block |
sim.rs | use col::CappedList;
use num::traits::Float;
use std::cmp::Ordering;
use strsim;
/// Gets the best jaro match for the input word.
pub fn best_match<'a>(dict: &'a [String], target: &'a str) -> Option<&'a str> {
let (_, word) = dict.iter()
.map(|word| (strsim::jaro(word, target), word))
.fold((0.0, "")... |
/// Gets the word with the least hamming distance from the target word.
pub fn best_hamming_match<'a>(dict: &'a [String], target: &'a str) -> Option<&'a str> {
let (_, word) = dict.iter()
.filter_map(|word| strsim::hamming(word, target).map(|score| (score, word)).ok())
.fold((usize::max_value(), ""... | {
let (_, word) = dict.iter()
.map(|word| (strsim::levenshtein(word, target), word))
.fold((usize::max_value(), ""), |(ar, aw), (br, bw)| if br < ar { (br, bw) } else { (ar, aw) });
if word != "" { Some(&word) } else { None }
} | identifier_body |
sim.rs | use col::CappedList;
use num::traits::Float;
use std::cmp::Ordering;
use strsim;
/// Gets the best jaro match for the input word.
pub fn best_match<'a>(dict: &'a [String], target: &'a str) -> Option<&'a str> {
let (_, word) = dict.iter()
.map(|word| (strsim::jaro(word, target), word))
.fold((0.0, "")... |
if word!= "" { Some(&word) } else { None }
} | pub fn best_hamming_match<'a>(dict: &'a [String], target: &'a str) -> Option<&'a str> {
let (_, word) = dict.iter()
.filter_map(|word| strsim::hamming(word, target).map(|score| (score, word)).ok())
.fold((usize::max_value(), ""), |(ar, aw), (br, bw)| if br < ar { (br, bw) } else { (ar, aw) }); | random_line_split |
db.rs | use std::{borrow::Cow, cell::RefCell, fmt::Write as FmtWrite};
use futures::{Future, FutureExt};
use nanorand::{WyRand, RNG};
use ntex::util::{Bytes, BytesMut};
use smallvec::SmallVec;
use tokio_postgres::types::ToSql;
use tokio_postgres::{connect, Client, Statement};
use yarte::{ywrite_html, Serialize};
#[cfg(target... | (db_url: &str) -> PgConnection {
let (cl, conn) = connect(db_url)
.await
.expect("can not connect to postgresql");
ntex::rt::spawn(conn.map(|_| ()));
let fortune = cl.prepare("SELECT * FROM fortune").await.unwrap();
let mut updates = Vec::new();
for num in ... | connect | identifier_name |
db.rs | use std::{borrow::Cow, cell::RefCell, fmt::Write as FmtWrite};
use futures::{Future, FutureExt};
use nanorand::{WyRand, RNG};
use ntex::util::{Bytes, BytesMut};
use smallvec::SmallVec;
use tokio_postgres::types::ToSql;
use tokio_postgres::{connect, Client, Statement};
use yarte::{ywrite_html, Serialize};
#[cfg(target... | }
}
impl PgConnection {
pub fn get_world(&self) -> impl Future<Output = Bytes> {
let random_id = (self.rng.borrow_mut().generate::<u32>() % 10_000 + 1) as i32;
self.cl.query(&self.world, &[&random_id]).map(|rows| {
let rows = rows.unwrap();
let mut body = BytesMut::new()... | world,
updates,
rng: RefCell::new(WyRand::new()),
} | random_line_split |
window.rs | use super::errors::{Error, ErrorKind, Result};
use super::platform;
use super::system::System;
use glium::{
glutin::{ | },
Display, Frame, Surface,
};
const OPENGL_DEPTH_SIZE: u8 = 24;
pub struct WindowConfig {
pub width: u32,
pub height: u32,
pub title: String,
}
pub struct Window {
display: Display,
event_loop: Option<EventLoop<()>>,
width: u32,
height: u32,
}
impl Window {
pub fn width(&sel... | dpi::PhysicalSize, event_loop::EventLoop, window::WindowBuilder, Api, ContextBuilder,
GlProfile, GlRequest, | random_line_split |
window.rs | use super::errors::{Error, ErrorKind, Result};
use super::platform;
use super::system::System;
use glium::{
glutin::{
dpi::PhysicalSize, event_loop::EventLoop, window::WindowBuilder, Api, ContextBuilder,
GlProfile, GlRequest,
},
Display, Frame, Surface,
};
const OPENGL_DEPTH_SIZE: u8 = 24;
... | (&self) -> u32 {
self.height
}
pub fn aspect_ratio(&self) -> f32 {
self.width as f32 / self.height as f32
}
pub fn draw(&self) -> Frame {
let mut frame = self.display.draw();
frame.clear_all_srgb((0.06, 0.07, 0.09, 0.0), 1.0, 0);
frame
}
pub fn facade(&... | height | identifier_name |
diaryid.rs | //
// imag - the personal information management suite for the commandline
// Copyright (C) 2015, 2016 Matthias Beyer <mail@beyermatthias.de> and contributors
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the ... |
pub fn diary_name(&self) -> &String {
&self.name
}
pub fn year(&self) -> i32 {
self.year
}
pub fn month(&self) -> u32 {
self.month
}
pub fn day(&self) -> u32 {
self.day
}
pub fn hour(&self) -> u32 {
self.hour
}
pub fn minute(&sel... | {
DiaryId::new(diary_name,
dt.year(),
dt.month(),
dt.day(),
dt.hour(),
dt.minute(),
dt.second())
} | identifier_body |
diaryid.rs | //
// imag - the personal information management suite for the commandline
// Copyright (C) 2015, 2016 Matthias Beyer <mail@beyermatthias.de> and contributors
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the ... | }
pub fn day(&self) -> u32 {
self.day
}
pub fn hour(&self) -> u32 {
self.hour
}
pub fn minute(&self) -> u32 {
self.minute
}
pub fn second(&self) -> u32 {
self.second
}
pub fn with_diary_name(mut self, name: String) -> DiaryId {
self.na... | pub fn month(&self) -> u32 {
self.month | random_line_split |
diaryid.rs | //
// imag - the personal information management suite for the commandline
// Copyright (C) 2015, 2016 Matthias Beyer <mail@beyermatthias.de> and contributors
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the ... | (self) -> StoreResult<StoreId> {
let s : String = self.into();
ModuleEntryPath::new(s).into_storeid()
}
}
impl Into<String> for DiaryId {
fn into(self) -> String {
format!("{}/{:0>4}/{:0>2}/{:0>2}/{:0>2}:{:0>2}:{:0>2}",
self.name, self.year, self.month, self.day, self.... | into_storeid | identifier_name |
day_9.rs | use alloc::raw_vec::RawVec;
use std::ops::{Deref, DerefMut};
use std::intrinsics::assume;
use std::{slice, ptr};
pub struct Stack<T> {
size: usize,
vec: RawVec<T>
}
impl <T> Deref for Stack<T> {
type Target = [T];
fn deref(&self) -> &[T] {
unsafe {
slice::from_raw_parts(self.as_p... | }
else {
self.size -= 1;
unsafe {
Some(ptr::read(self.get_unchecked(self.size)))
}
}
}
unsafe fn as_ptr(&self) -> *mut T {
let ptr = self.vec.ptr();
assume(!ptr.is_null());
ptr
}
} | }
pub fn pop(&mut self) -> Option<T> {
if self.is_empty() {
None | random_line_split |
day_9.rs | use alloc::raw_vec::RawVec;
use std::ops::{Deref, DerefMut};
use std::intrinsics::assume;
use std::{slice, ptr};
pub struct Stack<T> {
size: usize,
vec: RawVec<T>
}
impl <T> Deref for Stack<T> {
type Target = [T];
fn deref(&self) -> &[T] {
unsafe {
slice::from_raw_parts(self.as_p... | (&mut self) -> &mut [T] {
unsafe {
slice::from_raw_parts_mut(self.as_ptr(), self.size)
}
}
}
impl <T> Stack<T> {
pub fn new(max_size: usize) -> Stack<T> {
Stack { size: 0, vec: RawVec::with_capacity(max_size) }
}
pub fn size(&self) -> usize {
self.size
... | deref_mut | identifier_name |
day_9.rs | use alloc::raw_vec::RawVec;
use std::ops::{Deref, DerefMut};
use std::intrinsics::assume;
use std::{slice, ptr};
pub struct Stack<T> {
size: usize,
vec: RawVec<T>
}
impl <T> Deref for Stack<T> {
type Target = [T];
fn deref(&self) -> &[T] {
unsafe {
slice::from_raw_parts(self.as_p... |
}
pub fn pop(&mut self) -> Option<T> {
if self.is_empty() {
None
}
else {
self.size -= 1;
unsafe {
Some(ptr::read(self.get_unchecked(self.size)))
}
}
}
unsafe fn as_ptr(&self) -> *mut T {
let ptr =... | {
false
} | conditional_block |
day_9.rs | use alloc::raw_vec::RawVec;
use std::ops::{Deref, DerefMut};
use std::intrinsics::assume;
use std::{slice, ptr};
pub struct Stack<T> {
size: usize,
vec: RawVec<T>
}
impl <T> Deref for Stack<T> {
type Target = [T];
fn deref(&self) -> &[T] {
unsafe {
slice::from_raw_parts(self.as_p... |
} | {
let ptr = self.vec.ptr();
assume(!ptr.is_null());
ptr
} | identifier_body |
embedded-lib.rs | // Copyright 2017 GFX developers
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://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 tho... | let library = device.new_library_with_data(&library_data[..]).unwrap();
let kernel = library.get_function("sum", None).unwrap();
println!("Function name: {}", kernel.name());
println!("Function type: {:?}", kernel.function_type());
println!("OK");
unsafe {
msg_send![pool, release]
... | let pool = unsafe { NSAutoreleasePool::new(cocoa::base::nil) };
let device = Device::system_default();
| random_line_split |
embedded-lib.rs | // Copyright 2017 GFX developers
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://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 tho... | () {
let library_data = include_bytes!("default.metallib");
let pool = unsafe { NSAutoreleasePool::new(cocoa::base::nil) };
let device = Device::system_default();
let library = device.new_library_with_data(&library_data[..]).unwrap();
let kernel = library.get_function("sum", None).unwrap();
p... | main | identifier_name |
embedded-lib.rs | // Copyright 2017 GFX developers
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://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 tho... | {
let library_data = include_bytes!("default.metallib");
let pool = unsafe { NSAutoreleasePool::new(cocoa::base::nil) };
let device = Device::system_default();
let library = device.new_library_with_data(&library_data[..]).unwrap();
let kernel = library.get_function("sum", None).unwrap();
prin... | identifier_body | |
test.rs | #[macro_use] extern crate cfor;
#[test]
fn | () {
let mut tick = 0;
cfor!{let mut i = 1; i <= 0b1000_0000; i *= 2; {
tick += 1;
}}
assert_eq!(tick, 8);
tick = 0;
cfor!{let (mut a, mut b) = (0, 0); a + b < 20; { a += 1; b += 1; }; {
tick += 1;
}}
assert_eq!(tick, 10);
}
#[test]
#[should_panic]
fn continue_updates(... | smoketest | identifier_name |
test.rs | #[macro_use] extern crate cfor;
#[test]
fn smoketest() {
let mut tick = 0;
cfor!{let mut i = 1; i <= 0b1000_0000; i *= 2; {
tick += 1;
}}
assert_eq!(tick, 8);
tick = 0;
cfor!{let (mut a, mut b) = (0, 0); a + b < 20; { a += 1; b += 1; }; {
tick += 1;
}}
assert_eq!(tick,... | })
}
#[test]
fn missing_parts() {
let mut inside = false;
cfor!{;; (); {
inside = true;
break
}}
assert!(inside);
inside = false;
cfor!{();; (); {
inside = true;
break
}}
assert!(inside);
cfor!{; false; ; {
panic!()
}}
}
#[test]
fn ... | #[should_panic]
fn continue_updates() {
cfor!(let i = 0; i < 10; panic!(); {
// we *should* hit the step expression.
continue | random_line_split |
test.rs | #[macro_use] extern crate cfor;
#[test]
fn smoketest() |
#[test]
#[should_panic]
fn continue_updates() {
cfor!(let i = 0; i < 10; panic!(); {
// we *should* hit the step expression.
continue
})
}
#[test]
fn missing_parts() {
let mut inside = false;
cfor!{;; (); {
inside = true;
break
}}
assert!(inside);
inside =... | {
let mut tick = 0;
cfor!{let mut i = 1; i <= 0b1000_0000; i *= 2; {
tick += 1;
}}
assert_eq!(tick, 8);
tick = 0;
cfor!{let (mut a, mut b) = (0, 0); a + b < 20; { a += 1; b += 1; }; {
tick += 1;
}}
assert_eq!(tick, 10);
} | identifier_body |
rotate.rs | #pragma version(1)
#pragma rs java_package_name(de.markusfisch.android.binaryeye.rs)
#pragma rs_fp_relaxed
rs_allocation inImage;
int inWidth;
int inHeight;
uchar RS_KERNEL rotate90(const uchar in, uint32_t x, uint32_t y) {
const uchar *out = rsGetElementAt(inImage, y, inHeight - 1 - x);
return *out;
}
uchar RS_KE... | return *out;
} | uchar RS_KERNEL rotate270(const uchar in, uint32_t x, uint32_t y) {
const uchar *out = rsGetElementAt(inImage, inWidth - 1 - y, x); | random_line_split |
content_disposition.rs | // # References
//
// "The Content-Disposition Header Field" https://www.ietf.org/rfc/rfc2183.txt
// "The Content-Disposition Header Field in the Hypertext Transfer Protocol (HTTP)" https://www.ietf.org/rfc/rfc6266.txt
// "Returning Values from Forms: multipart/form-data" https://www.ietf.org/rfc/rfc2388.txt
// Browser... | (val: &str) -> ::Result<(Charset, Option<LanguageTag>, Vec<u8>)> {
// Break into three pieces separated by the single-quote character
let mut parts = val.splitn(3,'\'');
// Interpret the first piece as a Charset
let charset: Charset = match parts.next() {
None => return Err(::Error::Header),
... | parse_ext_value | identifier_name |
content_disposition.rs | // # References
//
// "The Content-Disposition Header Field" https://www.ietf.org/rfc/rfc2183.txt
// "The Content-Disposition Header Field in the Hypertext Transfer Protocol (HTTP)" https://www.ietf.org/rfc/rfc6266.txt
// "Returning Values from Forms: multipart/form-data" https://www.ietf.org/rfc/rfc2388.txt
// Browser... | ///
/// mime-charset = 1*mime-charsetc
/// mime-charsetc = ALPHA / DIGIT
/// / "!" / "#" / "$" / "%" / "&"
/// / "+" / "-" / "^" / "_" / "`"
/// / "{" / "}" / "~"
/// ; as <mime-charset> in Section 2.3 of [RFC2978]
/// ; except that the single quote... | random_line_split | |
supports_rule.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/. */
//! [@supports rules](https://drafts.csswg.org/css-conditional-3/#at-supports)
use cssparser::{Delimiter, parse_i... | <W>(&self, dest: &mut W) -> fmt::Result
where W: fmt::Write,
{
match *self {
SupportsCondition::Not(ref cond) => {
dest.write_str("not ")?;
cond.to_css(dest)
}
SupportsCondition::Parenthesized(ref cond) => {
dest.wri... | to_css | identifier_name |
supports_rule.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/. */
//! [@supports rules](https://drafts.csswg.org/css-conditional-3/#at-supports)
use cssparser::{Delimiter, parse_i... | first = false;
cond.to_css(dest)?;
}
Ok(())
}
SupportsCondition::Or(ref vec) => {
let mut first = true;
for cond in vec {
if!first {
dest.write_str(... | if !first {
dest.write_str(" and ")?;
} | random_line_split |
supports_rule.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/. */
//! [@supports rules](https://drafts.csswg.org/css-conditional-3/#at-supports)
use cssparser::{Delimiter, parse_i... |
SupportsCondition::Parenthesized(ref cond) => {
dest.write_str("(")?;
cond.to_css(dest)?;
dest.write_str(")")
}
SupportsCondition::And(ref vec) => {
let mut first = true;
for cond in vec {
... | {
dest.write_str("not ")?;
cond.to_css(dest)
} | conditional_block |
while-with-break.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () {
let mut i: int = 90;
while i < 100 {
println!("{}", i);
i = i + 1;
if i == 95 {
let _v: Vec<int> =
vec!(1, 2, 3, 4, 5); // we check that it is freed by break
println!("breaking");
break;
}
}
assert_eq!(i, 95);
}
| main | identifier_name |
while-with-break.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 ... |
}
assert_eq!(i, 95);
}
| {
let _v: Vec<int> =
vec!(1, 2, 3, 4, 5); // we check that it is freed by break
println!("breaking");
break;
} | conditional_block |
while-with-break.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | {
let mut i: int = 90;
while i < 100 {
println!("{}", i);
i = i + 1;
if i == 95 {
let _v: Vec<int> =
vec!(1, 2, 3, 4, 5); // we check that it is freed by break
println!("breaking");
break;
}
}
assert_eq!(i, 95);
} | identifier_body | |
while-with-break.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 ... | } | random_line_split | |
ns_css_value.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/. */
//! Little helpers for `nsCSSValue`.
use app_units::Au;
use gecko_bindings::bindings;
use gecko_bindings::structs... | impl Drop for nsCSSValue {
fn drop(&mut self) {
unsafe { bindings::Gecko_CSSValue_Drop(self) };
}
}
macro_rules! decl_cssarray_sugar {
($name:ident) => {
impl $name {
/// Return the length of this `nsCSSValue::Array`
#[inline]
pub fn len(&self) -> usize {
self.mCount
}
#[in... | random_line_split | |
ns_css_value.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/. */
//! Little helpers for `nsCSSValue`.
use app_units::Au;
use gecko_bindings::bindings;
use gecko_bindings::structs... | ,
nsCSSUnit::eCSSUnit_Percent => {
LengthOrPercentage::Percentage(bindings::Gecko_CSSValue_GetPercentage(self))
},
nsCSSUnit::eCSSUnit_Calc => {
LengthOrPercentage::Calc(bindings::Gecko_CSSValue_GetCalc(self).into())
},
x => pan... | {
LengthOrPercentage::Length(Au(bindings::Gecko_CSSValue_GetAbsoluteLength(self)))
} | conditional_block |
ns_css_value.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/. */
//! Little helpers for `nsCSSValue`.
use app_units::Au;
use gecko_bindings::bindings;
use gecko_bindings::structs... | (&mut self, lop: LengthOrPercentage) {
match lop {
LengthOrPercentage::Length(au) => {
bindings::Gecko_CSSValue_SetAbsoluteLength(self, au.0)
}
LengthOrPercentage::Percentage(pc) => {
bindings::Gecko_CSSValue_SetPercentage(self, pc)
... | set_lop | identifier_name |
ns_css_value.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/. */
//! Little helpers for `nsCSSValue`.
use app_units::Au;
use gecko_bindings::bindings;
use gecko_bindings::structs... |
/// Set to a string value
pub fn set_string(&mut self, s: &str) {
unsafe { bindings::Gecko_CSSValue_SetString(self, s.as_ptr(), s.len() as u32) }
}
/// Set to an identifier value
pub fn set_ident(&mut self, s: &str) {
unsafe { bindings::Gecko_CSSValue_SetIdent(self, s.as_ptr(), s.... | {
match self.mUnit {
nsCSSUnit::eCSSUnit_Pixel => {
LengthOrPercentage::Length(Au(bindings::Gecko_CSSValue_GetAbsoluteLength(self)))
},
nsCSSUnit::eCSSUnit_Percent => {
LengthOrPercentage::Percentage(bindings::Gecko_CSSValue_GetPercentage(self)... | identifier_body |
staging.rs | //! Staging protocols from wayland-protocols
//!
//! The protocols described this module are in the staging process and will soon be made part of a
//! release. Staging protocols are guaranteed to have no backwards incompatible changes introduced.
//!
//! These protocols are ready for wider adoption and clients and com... | //! receives the released event. Upon receiving the released event, the
//! client can safely cleanup any client-side resources.
#[allow(missing_docs)]
pub mod v1 {
wayland_protocol!(
"./protocols/staging/drm-lease/drm-lease-v1.xml",
[]
);
}
} | //! immediately send a released event and destroy the object. The client must
//! continue to process and discard drm_fd and connector events until it | random_line_split |
htmlbodyelement.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::attr::{Attr, AttrHelpers};
use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::Eve... | ;
evtarget.set_event_handler_uncompiled(cx, url, reflector,
&name[2..],
(**attr.value()).to_owned());
}
match attr.local_name() {
&atom!("bgcolor") => {
self.backg... | {
EventTargetCast::from_ref(*self)
} | conditional_block |
htmlbodyelement.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::attr::{Attr, AttrHelpers};
use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::Eve... |
#[allow(unsafe_code)]
fn get_background(self) -> Option<Url> {
unsafe {
self.background.borrow_for_layout().clone()
}
}
}
impl<'a> VirtualMethods for &'a HTMLBodyElement {
fn super_type<'b>(&'b self) -> Option<&'b VirtualMethods> {
let element: &&HTMLElement = HTML... | {
self.background_color.get()
} | identifier_body |
htmlbodyelement.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::attr::{Attr, AttrHelpers};
use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::Eve... | (&self) -> bool {
*self.type_id() == EventTargetTypeId::Node(NodeTypeId::Element(ElementTypeId::HTMLElement(
HTMLElementTypeId::HTMLBodyElement)))
}
}
impl HTMLBodyElement {
fn new_inherited(localName: DOMString, prefix: Option<DOMString>, document: &Document)
-... | is_htmlbodyelement | identifier_name |
htmlbodyelement.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::attr::{Attr, AttrHelpers};
use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::Eve... | } | random_line_split | |
lib.rs | // The MIT License (MIT)
// Copyright (c) 2015 Y. T. Chung <zonyitoo@gmail.com>
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// t... | <F, T>(f: F) -> JoinHandle<T>
where F: FnOnce() -> T + Send +'static,
T: Send +'static
{
Scheduler::spawn(f)
}
/// Spawn a new Coroutine with options
#[inline(always)]
pub fn spawn_opts<F, T>(f: F, opts: Options) -> JoinHandle<T>
where F: FnOnce() -> T + Send +'static,
T: Send +'static
... | spawn | identifier_name |
lib.rs | // The MIT License (MIT)
// Copyright (c) 2015 Y. T. Chung <zonyitoo@gmail.com>
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// t... | fn test_sleep_ms() {
spawn(|| {
sleep_ms(1000);
});
run(1);
}
#[test]
fn test_start_join() {
spawn(|| {});
start(1);
join();
}
} |
#[test] | random_line_split |
lib.rs | // The MIT License (MIT)
// Copyright (c) 2015 Y. T. Chung <zonyitoo@gmail.com>
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// t... |
}
| {
spawn(|| {});
start(1);
join();
} | identifier_body |
wf-trait-default-fn-ret.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 ... | { } | identifier_body | |
wf-trait-default-fn-ret.rs | // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Check that we test WF conditions for fn arguments. Because the
// current code is so ... | random_line_split | |
wf-trait-default-fn-ret.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 ... | () { }
| main | identifier_name |
id3.rs | use std::rc::Rc;
use std::cmp::Ordering;
use std::option::Option;
pub struct Node<T,C> {
pub leaf: Option<Rc<C>>,
pub func: Option<Rc<Fn(&T) -> bool>>,
pub left: Option<Rc<Node<T,C>>>,
pub right: Option<Rc<Node<T,C>>>
}
/*
pub fn build_func<C:Eq, T>(tree:Option<Rc<Node<T,C>>>)
... | <C:Eq, T>(dataset:&Vec<(Rc<T>, Rc<C>)>,
rules:&Vec<Rc<Fn(&T)->bool>>,
gain:Rc<Fn(&Vec<(Rc<T>, Rc<C>)>, Rc<C>)->f64>)
-> Option<Rc<Node<T,C>>> {
if dataset.len() == 0 || rules.len() == 0 {
return None;
}
let classes: Vec<R... | create_tree | identifier_name |
id3.rs | use std::rc::Rc;
use std::cmp::Ordering;
use std::option::Option;
pub struct Node<T,C> {
pub leaf: Option<Rc<C>>,
pub func: Option<Rc<Fn(&T) -> bool>>,
pub left: Option<Rc<Node<T,C>>>,
pub right: Option<Rc<Node<T,C>>>
}
/*
pub fn build_func<C:Eq, T>(tree:Option<Rc<Node<T,C>>>)
... | Rc::get_mut(&mut right).unwrap().push(d.clone());
}
}
for c in &classes {
score.push((r,
c.clone(),
gain(&left, c.clone()),
left.clone(),
gain(&right, c.clone()),
... | {
if dataset.len() == 0 || rules.len() == 0 {
return None;
}
let classes: Vec<Rc<C>> = dataset.iter().map(|x| {x.1.clone()}).collect();
let mut score = Vec::new();
if classes.len() == 1 {
return Some(Rc::new(Node{leaf:Some(classes[0].clone()), func:None, left:None, right:None}));... | identifier_body |
id3.rs | use std::rc::Rc;
use std::cmp::Ordering;
use std::option::Option;
pub struct Node<T,C> {
pub leaf: Option<Rc<C>>,
pub func: Option<Rc<Fn(&T) -> bool>>,
pub left: Option<Rc<Node<T,C>>>,
pub right: Option<Rc<Node<T,C>>>
}
/*
pub fn build_func<C:Eq, T>(tree:Option<Rc<Node<T,C>>>)
... |
for r in rules.iter().enumerate() {
let mut right = Rc::new(Vec::new());
let mut left = Rc::new(Vec::new());
for d in dataset {
if r.1(&d.0) {
Rc::get_mut(&mut left).unwrap().push(d.clone())
}
else {
Rc::get_mut(&mut right)... | {
return Some(Rc::new(Node{leaf:Some(classes[0].clone()), func:None, left:None, right:None}));
} | conditional_block |
id3.rs | use std::rc::Rc;
use std::cmp::Ordering;
use std::option::Option;
pub struct Node<T,C> {
pub leaf: Option<Rc<C>>,
pub func: Option<Rc<Fn(&T) -> bool>>,
pub left: Option<Rc<Node<T,C>>>,
pub right: Option<Rc<Node<T,C>>>
}
/*
pub fn build_func<C:Eq, T>(tree:Option<Rc<Node<T,C>>>)
... | new_rules.remove((score[0].0).0);
score.sort_by(|x, y| {
if x.2 < y.2 && x.4 < y.4 {
return Ordering::Less
}
if x.2 == y.2 && x.4 == y.4 {
return Ordering::Equal
}
return Ordering::Greater
});
Some(Rc::new(Node{
func: Some((score[0... | right.clone()));
}
}
let mut new_rules = rules.clone(); | random_line_split |
adjancency_list.rs | use route_node::RouteNode;
use edge::Edge;
// returns a vector containing vector of edges that are reachable from given node
pub fn construct(routes: Vec<RouteNode>) -> Vec<Vec<Edge>> {
// there probably is a smarter way of doing this
// basically we need to ensure that the adjanency list has a
// size of large... |
}
// initialize the list with empty vectors. largest node + 1 is so that indexing
// the vector with [largest_node] is allowed.
let mut list:Vec<Vec<Edge>> = range(0, largest_node + 1).map(|_| vec![]).collect();
for node in routes.iter() {
list[node.from].push(Edge::new(node.to, node.weight));
}
l... | {
largest_node = node.to;
} | conditional_block |
adjancency_list.rs | use route_node::RouteNode;
use edge::Edge; | // returns a vector containing vector of edges that are reachable from given node
pub fn construct(routes: Vec<RouteNode>) -> Vec<Vec<Edge>> {
// there probably is a smarter way of doing this
// basically we need to ensure that the adjanency list has a
// size of largest node + 1 so that we do not get out of bou... | random_line_split | |
adjancency_list.rs | use route_node::RouteNode;
use edge::Edge;
// returns a vector containing vector of edges that are reachable from given node
pub fn | (routes: Vec<RouteNode>) -> Vec<Vec<Edge>> {
// there probably is a smarter way of doing this
// basically we need to ensure that the adjanency list has a
// size of largest node + 1 so that we do not get out of bounds errors when
// using the list to check node's neighbours.
let mut largest_node:usize = 0;... | construct | identifier_name |
adjancency_list.rs | use route_node::RouteNode;
use edge::Edge;
// returns a vector containing vector of edges that are reachable from given node
pub fn construct(routes: Vec<RouteNode>) -> Vec<Vec<Edge>> | // the vector with [largest_node] is allowed.
let mut list:Vec<Vec<Edge>> = range(0, largest_node + 1).map(|_| vec![]).collect();
for node in routes.iter() {
list[node.from].push(Edge::new(node.to, node.weight));
}
list
}
| {
// there probably is a smarter way of doing this
// basically we need to ensure that the adjanency list has a
// size of largest node + 1 so that we do not get out of bounds errors when
// using the list to check node's neighbours.
let mut largest_node:usize = 0;
for node in routes.iter() {
if node... | identifier_body |
lib.rs | //! Runtime-checked non-NaN floating point numbers with total ordering.
extern crate num;
extern crate quickcheck;
use std::ops::Deref;
use std::cmp::Ordering;
use std::borrow::Borrow;
use num::{Float, NumCast, ToPrimitive, FromPrimitive, Bounded};
use quickcheck::{Arbitrary, Gen};
fn map_nan<T: Float>(n: T) -> Opt... | else {
Some(Real(n))
}
}
pub type Real32 = Real<f32>;
pub type Real64 = Real<f64>;
/// Runtime-checked non-NaN floating point numbers with total ordering.
///
/// Useful for putting floats in data structures that require a total ordering
/// (i.e. situations where NaN would not be valid anyway).
///
///... | {
None
} | conditional_block |
lib.rs | //! Runtime-checked non-NaN floating point numbers with total ordering.
extern crate num;
extern crate quickcheck;
use std::ops::Deref;
use std::cmp::Ordering;
use std::borrow::Borrow;
use num::{Float, NumCast, ToPrimitive, FromPrimitive, Bounded};
use quickcheck::{Arbitrary, Gen};
fn map_nan<T: Float>(n: T) -> Opt... | fn partial_cmp(&self, other: &Real<T>) -> Option<Ordering> {
Some(self.cmp(other))
}
}
impl<T: Float> PartialOrd<T> for Real<T> {
fn partial_cmp(&self, other: &T) -> Option<Ordering> {
self.0.partial_cmp(other)
}
}
impl<T: Float> PartialEq<T> for Real<T> {
fn eq(&self, other: &T) -... | }
}
impl<T: Float> PartialOrd for Real<T> { | random_line_split |
lib.rs | //! Runtime-checked non-NaN floating point numbers with total ordering.
extern crate num;
extern crate quickcheck;
use std::ops::Deref;
use std::cmp::Ordering;
use std::borrow::Borrow;
use num::{Float, NumCast, ToPrimitive, FromPrimitive, Bounded};
use quickcheck::{Arbitrary, Gen};
fn map_nan<T: Float>(n: T) -> Opt... |
}
impl<T: Float> Borrow<T> for Real<T> {
fn borrow(&self) -> &T {
&self.0
}
}
impl<T: Arbitrary + Float> Arbitrary for Real<T> {
fn arbitrary<G: Gen>(g: &mut G) -> Real<T> {
let mut ar = T::arbitrary(g);
while ar.is_nan() {
ar = T::arbitrary(g);
}
Real(... | {
&self.0
} | identifier_body |
lib.rs | //! Runtime-checked non-NaN floating point numbers with total ordering.
extern crate num;
extern crate quickcheck;
use std::ops::Deref;
use std::cmp::Ordering;
use std::borrow::Borrow;
use num::{Float, NumCast, ToPrimitive, FromPrimitive, Bounded};
use quickcheck::{Arbitrary, Gen};
fn map_nan<T: Float>(n: T) -> Opt... | (&self) -> Option<i32> { self.0.to_i32() }
fn to_i64 (&self) -> Option<i64> { self.0.to_i64() }
fn to_usize(&self) -> Option<usize> { self.0.to_usize() }
fn to_u8 (&self) -> Option<u8> { self.0.to_u8() }
fn to_u16 (&self) -> Option<u16> { self.0.to_u16() }
fn to_u32 (&self) ... | to_i32 | identifier_name |
df.rs | //! ## Example
//!
//! let ctx = TokamakContext::new();
//! ctx.from(RandomGenerator).select(...);
use algebra::*;
use common::dataset::DataSet;
use common::err::{Error, Result};
use engine::QueryRunner;
use super::TokamakContext;
pub struct DataFrame<'a> {
pub ctx: &'a TokamakContext,
pub plan: Operator,
}
imp... | (&self) -> Result<usize> {
// let count_plan = Plan::Aggregate(self.decl, vec![], vec!["count(*)"]);
// try!(execute(count_plan)).get_int8(0)
Err(Error::NotImplemented)
}
pub fn head(self) -> Result<DataSet> {
self.head_with(1)
}
pub fn head_with(self, num: usize) -> Result<DataSet> {
... | count | identifier_name |
df.rs | //! ## Example
//!
//! let ctx = TokamakContext::new();
//! ctx.from(RandomGenerator).select(...);
use algebra::*;
use common::dataset::DataSet;
use common::err::{Error, Result};
use engine::QueryRunner;
use super::TokamakContext;
pub struct DataFrame<'a> {
pub ctx: &'a TokamakContext,
pub plan: Operator,
}
imp... |
}
| {
let tail_plan = Operator::Tail(Box::new(self.plan), num);
self.ctx.runner().execute(&self.ctx.session, &tail_plan)
} | identifier_body |
df.rs | //! ## Example
//!
//! let ctx = TokamakContext::new();
//! ctx.from(RandomGenerator).select(...);
use algebra::*;
use common::dataset::DataSet;
use common::err::{Error, Result};
use engine::QueryRunner;
use super::TokamakContext;
pub struct DataFrame<'a> {
pub ctx: &'a TokamakContext,
pub plan: Operator,
}
imp... | DataFrame {
ctx: self.ctx,
plan: Operator::Project(Box::new(self.plan), exprs),
}
}
pub fn count(&self) -> Result<usize> {
// let count_plan = Plan::Aggregate(self.decl, vec![], vec!["count(*)"]);
// try!(execute(count_plan)).get_int8(0)
Err(Error::NotImplemented)
}
pub f... | }
}
pub fn select(self, exprs: Vec<Operator>) -> DataFrame<'a> { | random_line_split |
thirteen.rs | extern crate num;
use self::num::bigint::BigInt;
use std::str::FromStr;
pub fn run() | BigInt::from_str("54370070576826684624621495650076471787294438377604").unwrap(),
BigInt::from_str("53282654108756828443191190634694037855217779295145").unwrap(),
BigInt::from_str("36123272525000296071075082563815656710885258350721").unwrap(),
BigInt::from_str("4587657617241097644733911060721826523687722... | {
let nums: Vec<BigInt> = vec![
BigInt::from_str("37107287533902102798797998220837590246510135740250").unwrap(),
BigInt::from_str("46376937677490009712648124896970078050417018260538").unwrap(),
BigInt::from_str("74324986199524741059474233309513058123726617309629").unwrap(),
BigInt::from_str("919422133... | identifier_body |
thirteen.rs | extern crate num;
use self::num::bigint::BigInt;
use std::str::FromStr;
pub fn | () {
let nums: Vec<BigInt> = vec![
BigInt::from_str("37107287533902102798797998220837590246510135740250").unwrap(),
BigInt::from_str("46376937677490009712648124896970078050417018260538").unwrap(),
BigInt::from_str("74324986199524741059474233309513058123726617309629").unwrap(),
BigInt::from_str("919422... | run | identifier_name |
thirteen.rs | extern crate num;
use self::num::bigint::BigInt;
use std::str::FromStr;
pub fn run() {
let nums: Vec<BigInt> = vec![
BigInt::from_str("37107287533902102798797998220837590246510135740250").unwrap(),
BigInt::from_str("46376937677490009712648124896970078050417018260538").unwrap(),
BigInt::from_str("7432498... | BigInt::from_str("29746152185502371307642255121183693803580388584903").unwrap(),
BigInt::from_str("41698116222072977186158236678424689157993532961922").unwrap(),
BigInt::from_str("62467957194401269043877107275048102390895523597457").unwrap(),
BigInt::from_str("2318970677254791506150550495392297953090112... | BigInt::from_str("18495701454879288984856827726077713721403798879715").unwrap(),
BigInt::from_str("38298203783031473527721580348144513491373226651381").unwrap(),
BigInt::from_str("34829543829199918180278916522431027392251122869539").unwrap(),
BigInt::from_str("4095795306640523263253804410005965493915987... | random_line_split |
macros.rs | // Copyright 2021 The Grin Developers
//
// 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 agree... | /// Same as try_map_vec when thing is an iterator
#[macro_export]
macro_rules! try_iter_map_vec {
($thing:expr, $mapfn:expr) => {
$thing.map($mapfn).collect::<Result<Vec<_>, _>>()?;
};
}
/// Eliminates some of the verbosity in having iter and collect
/// around every filter_map call.
#[macro_export]
macro_rules! f... | random_line_split | |
lib.rs | // Copyright 2014 Colin Sherratt
//
// 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 o... | let id = db.new_material(mat);
name_to_id.insert(m.name.clone(), id);
}
name_to_id
}
pub fn import<G: Graphics>(&self, gd: &mut G) -> HashMap<String, Entity> {
let textures = self.write_textures(gd);
let materials = self.write_materials(gd, &textures);
... | {
let mut name_to_id = HashMap::new();
let lookup = |name| {
*text.get(name).expect("texture not found")
};
for m in self.materials.iter() {
let mut mat = graphics::Material::new();
if m.ka.is_some() { mat.set_ka(*m.ka.as_ref().unwrap()); }
... | identifier_body |
lib.rs | // Copyright 2014 Colin Sherratt
//
// 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 o... | {
path: Path,
materials: Vec<obj::Material>,
obj: obj::Obj<String>
}
impl Obj {
pub fn load(path: &Path) -> IoResult<Obj> {
File::open(path).map(|f| {
let mut f = BufferedReader::new(f);
let obj = obj::Obj::load(&mut f);
let mut materials = Vec::new();
... | Obj | identifier_name |
lib.rs | // Copyright 2014 Colin Sherratt
//
// 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 o... |
};
vertices.push(vert)
});
g.indices().iter()
.map(|x| *x)
.triangulate()
.vertex(|v| indexer.index(v) as u32)
.vertices()
.collect()
};
... | {
VertexGeoTexNorm {
position: self.obj.position()[p],
texture: [0., 0.],
normal: [1., 0., 0.]
}
} | conditional_block |
lib.rs | // Copyright 2014 Colin Sherratt
//
// 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 o... | }).collect()
}
} | random_line_split | |
statement.rs | // Copyright 2017 The nom-lua project developers
//
// 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
// e... | //for in (deps exp, explist, block)
//function (deps funcname)
//parse_local_function
//local (deps namelist, explist)
));
named!(pub parse_retstat<ASTNode>, map!(map!(
delimited!(
tag!("return"),
ws!(opt!(complete!(parse_explist))),
opt!(comp... | random_line_split | |
column.mako.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/. */
<%namespace name="helpers" file="/helpers.mako.rs" />
<% data.new_style_struct("Column", inherited=False) %>
// ... | () -> SpecifiedValue {
BorderWidth::Medium
}
pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
BorderWidth::parse(context, input)
}
</%helpers:longhand>
// https://drafts.csswg.org/css-multicol-1/#crc
${helpers.predefined_type("column-rule-color", "C... | get_initial_specified_value | identifier_name |
column.mako.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/. */
<%namespace name="helpers" file="/helpers.mako.rs" />
<% data.new_style_struct("Column", inherited=False) %>
// ... | parse_method="parse_non_negative_length",
extra_prefixes="moz",
boxed=True,
animation_type="none",
experimental=True,
spec="https://drafts.csswg.org/css-multicol/#p... | "length::LengthOrAuto",
"Either::Second(Auto)",
initial_specified_value="Either::Second(Auto)", | random_line_split |
column.mako.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/. */
<%namespace name="helpers" file="/helpers.mako.rs" />
<% data.new_style_struct("Column", inherited=False) %>
// ... |
</%helpers:longhand>
// https://drafts.csswg.org/css-multicol-1/#crc
${helpers.predefined_type("column-rule-color", "CSSColor",
"::cssparser::Color::CurrentColor",
initial_specified_value="specified::CSSColor::currentcolor()",
products="gec... | {
BorderWidth::parse(context, input)
} | identifier_body |
struct_array_copy.rs |
// Copyright (C) 2011 The Android Open Source Project
//
// 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 appli... | {
struct myStruct inner;
};
void bar() {
struct myStruct localStruct;
localStruct.i = 5;
mS = localStruct;
}
int root(int num) {
return 10;
}
| outerStruct | identifier_name |
struct_array_copy.rs | // Copyright (C) 2011 The Android Open Source Project
//
// 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 applic... | };
void bar() {
struct myStruct localStruct;
localStruct.i = 5;
mS = localStruct;
}
int root(int num) {
return 10;
} |
struct outerStruct {
struct myStruct inner; | random_line_split |
popup_menu.rs | use std::cell::RefCell;
use std::cmp::min;
use std::iter;
use std::rc::Rc;
use gdk::{EventButton, EventType};
use glib;
use gtk;
use gtk::prelude::*;
use pango;
use neovim_lib::{Neovim, NeovimApi};
use crate::highlight::HighlightMap;
use crate::input;
use crate::nvim::{self, ErrorReport, NeovimClient};
use crate::re... | else if target_idx > selected_idx {
target_idx - selected_idx
} else {
selected_idx - target_idx
}
}
fn on_treeview_allocate(
scroll: >k::ScrolledWindow,
tree: >k::TreeView,
renderer: >k::CellRendererText,
) {
let treeview_height = calc_treeview_height(tree, renderer);
... | {
target_idx + 1
} | conditional_block |
popup_menu.rs | use std::cell::RefCell;
use std::cmp::min;
use std::iter;
use std::rc::Rc;
use gdk::{EventButton, EventType};
use glib;
use gtk;
use gtk::prelude::*;
use pango;
use neovim_lib::{Neovim, NeovimApi};
use crate::highlight::HighlightMap;
use crate::input;
use crate::nvim::{self, ErrorReport, NeovimClient};
use crate::re... | pub hl: &'a HighlightMap,
pub font_ctx: &'a render::Context,
pub menu_items: &'a [nvim::CompleteItem<'a>],
pub selected: i64,
pub x: i32,
pub y: i32,
pub width: i32,
pub height: i32,
pub max_width: i32,
}
pub fn tree_button_press(
tree: >k::TreeView,
ev: &EventButton,
... |
pub struct PopupMenuContext<'a> {
pub nvim: &'a Rc<NeovimClient>, | random_line_split |
popup_menu.rs | use std::cell::RefCell;
use std::cmp::min;
use std::iter;
use std::rc::Rc;
use gdk::{EventButton, EventType};
use glib;
use gtk;
use gtk::prelude::*;
use pango;
use neovim_lib::{Neovim, NeovimApi};
use crate::highlight::HighlightMap;
use crate::input;
use crate::nvim::{self, ErrorReport, NeovimClient};
use crate::re... |
pub fn show(&mut self, ctx: PopupMenuContext) {
self.open = true;
self.popover.set_pointing_to(>k::Rectangle {
x: ctx.x,
y: ctx.y,
width: ctx.width,
height: ctx.height,
});
self.state.borrow_mut().before_show(ctx);
self.pop... | {
self.open
} | identifier_body |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.