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 |
|---|---|---|---|---|
test.rs | text
/* this is a
/* nested
block */ comment.
And should stay a comment
even with "strings"
or 42 0x18 0b01011 // blah
or u32 as i16 if impl */
text
/** this is a
/*! nested
block */ doc comment */
text
/// test
/// *test*
/// **test**
/// ***test***
/// _test_
/// __test__
/// __***test***__
/// ___test___
/// # te... | text r##"This is ##"# also valid."## text
text r#"This is #"## not valid."# text //"
text b"This is a bytestring" text
text br"And a raw byte string" text
text rb"Invalid raw byte string" text
text br##"This is ##"# also valid."## text
text r##"Raw strings can
span multiple lines"## text
text "double-quote string" te... |
text r"This is a raw string" text
text r"This raw string ends in \" text
text r#"This is also valid"# text | random_line_split |
sync.rs | // * This file is part of the uutils coreutils package.
// *
// * (c) Alexander Fomin <xander.fomin@ya.ru>
// *
// * For the full copyright and license information, please view the LICENSE
// * file that was distributed with this source code.
/* Last synced with: sync (GNU coreutils) 8.13 */
extern crate libc;
... | #[allow(deprecated)]
let mut name: [winnt::WCHAR; minwindef::MAX_PATH] = mem::uninitialized();
if winapi::um::fileapi::FindNextVolumeW(
next_volume_handle,
name.as_mut_ptr(),
name.len() as minwindef::DWORD,
) == 0
... |
unsafe fn find_all_volumes() -> Vec<String> {
let (first_volume, next_volume_handle) = find_first_volume();
let mut volumes = vec![first_volume];
loop { | random_line_split |
sync.rs | // * This file is part of the uutils coreutils package.
// *
// * (c) Alexander Fomin <xander.fomin@ya.ru>
// *
// * For the full copyright and license information, please view the LICENSE
// * file that was distributed with this source code.
/* Last synced with: sync (GNU coreutils) 8.13 */
extern crate libc;
... |
pub unsafe fn do_syncfs(files: Vec<String>) -> isize {
for path in files {
flush_volume(
Path::new(&path)
.components()
.next()
.unwrap()
.as_os_str()
.to_str()
.un... | {
let volumes = find_all_volumes();
for vol in &volumes {
flush_volume(vol);
}
0
} | identifier_body |
sync.rs | // * This file is part of the uutils coreutils package.
// *
// * (c) Alexander Fomin <xander.fomin@ya.ru>
// *
// * For the full copyright and license information, please view the LICENSE
// * file that was distributed with this source code.
/* Last synced with: sync (GNU coreutils) 8.13 */
extern crate libc;
... | (name: &str) {
let name_wide = name.to_wide_null();
if winapi::um::fileapi::GetDriveTypeW(name_wide.as_ptr()) == winbase::DRIVE_FIXED {
let sliced_name = &name[..name.len() - 1]; // eliminate trailing backslash
match OpenOptions::new().write(true).open(sliced_name) {
... | flush_volume | identifier_name |
types.rs | extern crate serde_json;
extern crate rmp_serde;
use std::cmp::Eq;
use std::collections::HashMap;
use std::hash::{Hash, Hasher};
use super::zmq;
use errors::common::CommonError;
use services::ledger::merkletree::merkletree::MerkleTree;
use utils::json::{JsonDecodable, JsonEncodable};
#[derive(Serialize, Deserialize,... | #[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct Response {
pub req_id: u64,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct PoolLedgerTxns {
pub txn: Response,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct SimpleRequest {
... | #[derive(Serialize, Deserialize, Debug)]
pub struct Reply {
pub result: Response,
}
| random_line_split |
types.rs | extern crate serde_json;
extern crate rmp_serde;
use std::cmp::Eq;
use std::collections::HashMap;
use std::hash::{Hash, Hasher};
use super::zmq;
use errors::common::CommonError;
use services::ledger::merkletree::merkletree::MerkleTree;
use utils::json::{JsonDecodable, JsonEncodable};
#[derive(Serialize, Deserialize,... | (str: &str) -> Result<Message, serde_json::Error> {
match str {
"po" => Ok(Message::Pong),
"pi" => Ok(Message::Ping),
_ => Message::from_json(str),
}
}
}
impl JsonEncodable for Message {}
impl<'a> JsonDecodable<'a> for Message {}
#[derive(Serialize, Deserialize... | from_raw_str | identifier_name |
empty.rs | use crate::Stream;
use core::marker::PhantomData;
use core::pin::Pin;
use core::task::{Context, Poll};
/// Stream for the [`empty`](fn@empty) function.
#[derive(Debug)]
#[must_use = "streams do nothing unless polled"]
pub struct Empty<T>(PhantomData<T>);
impl<T> Unpin for Empty<T> {}
unsafe impl<T> Send for Empty<T>... | }
impl<T> Stream for Empty<T> {
type Item = T;
fn poll_next(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Option<T>> {
Poll::Ready(None)
}
fn size_hint(&self) -> (usize, Option<usize>) {
(0, Some(0))
}
} | pub const fn empty<T>() -> Empty<T> {
Empty(PhantomData) | random_line_split |
empty.rs | use crate::Stream;
use core::marker::PhantomData;
use core::pin::Pin;
use core::task::{Context, Poll};
/// Stream for the [`empty`](fn@empty) function.
#[derive(Debug)]
#[must_use = "streams do nothing unless polled"]
pub struct Empty<T>(PhantomData<T>);
impl<T> Unpin for Empty<T> {}
unsafe impl<T> Send for Empty<T>... | (&self) -> (usize, Option<usize>) {
(0, Some(0))
}
}
| size_hint | identifier_name |
mod.rs | //! Platform-specific extensions to `std` for Windows.
//!
//! Provides access to platform-level information for Windows, and exposes
//! Windows-specific idioms that would otherwise be inappropriate as part
//! the core `std` library. These extensions allow developers to use
//! `std` types and idioms with Windows in ... | #[doc(no_inline)]
#[stable(feature = "file_offset", since = "1.15.0")]
pub use super::fs::FileExt;
#[doc(no_inline)]
#[stable(feature = "rust1", since = "1.0.0")]
pub use super::fs::{MetadataExt, OpenOptionsExt};
#[doc(no_inline)]
#[stable(feature = "rust1", since = "1.0.0")]
pub use... | pub mod prelude {
#[doc(no_inline)]
#[stable(feature = "rust1", since = "1.0.0")]
pub use super::ffi::{OsStrExt, OsStringExt}; | random_line_split |
main.rs | extern crate itertools;
extern crate clap;
extern crate rand;
use itertools::Itertools;
use clap::{App, Arg};
use std::fs::File;
use rand::Rng;
use std::io::{Read, Write};
const DEFAULT_CROSSOVER_POINTS: usize = 3;
const DEFAULT_MUTATION_RATE: f64 = 0.001;
const DEFAULT_UNIT: usize = 1;
const DEFAULT_STRIDE: usize = 1... | }
v
},
Err(e) => {
println!("Could not open file \"{}\": {}", filenames.0, e);
return;
},
}, match File::open(filenames.1) {
Ok(mut f) => {
let mut v = Vec::new();
matc... | random_line_split | |
main.rs | extern crate itertools;
extern crate clap;
extern crate rand;
use itertools::Itertools;
use clap::{App, Arg};
use std::fs::File;
use rand::Rng;
use std::io::{Read, Write};
const DEFAULT_CROSSOVER_POINTS: usize = 3;
const DEFAULT_MUTATION_RATE: f64 = 0.001;
const DEFAULT_UNIT: usize = 1;
const DEFAULT_STRIDE: usize = 1... | .long("mutation-rate")
.value_name("RATE")
.help("Takes a RATE of mutation that randomizes UNIT bytes at a time")
.takes_value(true))
.arg(Arg::with_name("crossover-points")
.short("c")
.multiple(false)
.long("crossover-points")
... | {
let matches = App::new("matef")
.version("1.0")
.author("Geordon Worley <vadixidav@gmail.com>")
.about("Mates two files")
.arg(Arg::with_name("output")
.help("The output location")
.required(true)
.index(1))
.arg(Arg::with_name("file1")
... | identifier_body |
main.rs | extern crate itertools;
extern crate clap;
extern crate rand;
use itertools::Itertools;
use clap::{App, Arg};
use std::fs::File;
use rand::Rng;
use std::io::{Read, Write};
const DEFAULT_CROSSOVER_POINTS: usize = 3;
const DEFAULT_MUTATION_RATE: f64 = 0.001;
const DEFAULT_UNIT: usize = 1;
const DEFAULT_STRIDE: usize = 1... | () {
let matches = App::new("matef")
.version("1.0")
.author("Geordon Worley <vadixidav@gmail.com>")
.about("Mates two files")
.arg(Arg::with_name("output")
.help("The output location")
.required(true)
.index(1))
.arg(Arg::with_name("file1")
... | main | identifier_name |
typeck-unsafe-always-share.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | test(uns);
let ms = MySync{u: uns};
test(ms);
let ns = NoSync{m: marker::NoSync};
test(ns);
//~^ ERROR `core::kinds::Sync` is not implemented
} | fn main() {
let us = UnsafeCell::new(MySync{u: UnsafeCell::new(0i)});
test(us);
let uns = UnsafeCell::new(NoSync{m: marker::NoSync}); | random_line_split |
typeck-unsafe-always-share.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
fn main() {
let us = UnsafeCell::new(MySync{u: UnsafeCell::new(0i)});
test(us);
let uns = UnsafeCell::new(NoSync{m: marker::NoSync});
test(uns);
let ms = MySync{u: uns};
test(ms);
let ns = NoSync{m: marker::NoSync};
test(ns);
//~^ ERROR `core::kinds::Sync` is not implemented
}
| {
} | identifier_body |
typeck-unsafe-always-share.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | <T> {
u: UnsafeCell<T>
}
struct NoSync {
m: marker::NoSync
}
fn test<T: Sync>(s: T){
}
fn main() {
let us = UnsafeCell::new(MySync{u: UnsafeCell::new(0i)});
test(us);
let uns = UnsafeCell::new(NoSync{m: marker::NoSync});
test(uns);
let ms = MySync{u: uns};
test(ms);
let ns = N... | MySync | identifier_name |
exec.rs | #![feature(test)]
extern crate rasen;
extern crate rasen_dsl;
extern crate test;
use rasen_dsl::prelude::*;
use std::f32::consts::PI;
use test::Bencher;
include!("../../tests/dsl.rs");
#[bench]
fn bench_run_basic_frag(b: &mut Bencher) {
b.iter(|| {
basic_frag(
vec3(0.0f32, 1.0f32, 0.0f32),
... | {
b.iter(|| {
functions(Value::of(PI));
});
} | identifier_body | |
exec.rs | #![feature(test)]
extern crate rasen;
extern crate rasen_dsl;
extern crate test;
use rasen_dsl::prelude::*;
use std::f32::consts::PI;
use test::Bencher;
include!("../../tests/dsl.rs");
#[bench]
fn | (b: &mut Bencher) {
b.iter(|| {
basic_frag(
vec3(0.0f32, 1.0f32, 0.0f32),
vec2(0.0f32, 0.0f32),
Value::of(Sampler(Vec4([0.25f32, 0.625f32, 1.0f32, 1.0f32]))),
);
});
}
#[bench]
fn bench_run_basic_vert(b: &mut Bencher) {
b.iter(|| {
let a_pos = vec... | bench_run_basic_frag | identifier_name |
exec.rs | #![feature(test)]
extern crate rasen;
extern crate rasen_dsl;
extern crate test;
use rasen_dsl::prelude::*;
use std::f32::consts::PI;
use test::Bencher;
include!("../../tests/dsl.rs");
#[bench]
fn bench_run_basic_frag(b: &mut Bencher) {
b.iter(|| {
basic_frag(
vec3(0.0f32, 1.0f32, 0.0f32),
... | 1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0
]);
#[rustfmt::skip]
let view = Mat4([
1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0
... | let a_uv = vec2(0.5f32, 0.5f32);
#[rustfmt::skip]
let projection = Mat4([ | random_line_split |
init.rs | use disk::ahci::Ahci;
use disk::ide::Ide;
use env::Environment;
use schemes::file::FileScheme;
use super::config::PciConfig;
use super::common::class::*;
use super::common::subclass::*;
use super::common::programming_interface::*;
/*
use super::common::vendorid::*;
use super::common::deviceid::*;
use audio::ac97::... | }
}
}
}
} | ((id >> 16) & 0xFFFF) as u16); | random_line_split |
init.rs | use disk::ahci::Ahci;
use disk::ide::Ide;
use env::Environment;
use schemes::file::FileScheme;
use super::config::PciConfig;
use super::common::class::*;
use super::common::subclass::*;
use super::common::programming_interface::*;
/*
use super::common::vendorid::*;
use super::common::deviceid::*;
use audio::ac97::... |
(MASS_STORAGE, SATA, AHCI) => {
if let Some(module) = FileScheme::new(Ahci::disks(pci)) {
env.schemes.lock().push(module);
}
}
/*
(SERIAL_BUS, USB, UHCI) => env.schemes.lock().push(Uhci::new(pci)),
(SERIAL_BUS, USB, OHCI) => env.schemes.lo... | {
if let Some(module) = FileScheme::new(Ide::disks(pci)) {
env.schemes.lock().push(module);
}
} | conditional_block |
init.rs | use disk::ahci::Ahci;
use disk::ide::Ide;
use env::Environment;
use schemes::file::FileScheme;
use super::config::PciConfig;
use super::common::class::*;
use super::common::subclass::*;
use super::common::programming_interface::*;
/*
use super::common::vendorid::*;
use super::common::deviceid::*;
use audio::ac97::... | (env: &mut Environment,
pci: PciConfig,
class_id: u8,
subclass_id: u8,
interface_id: u8,
vendor_code: u16,
device_code: u16) {
match (class_id, subclass_id, interface... | pci_device | identifier_name |
init.rs | use disk::ahci::Ahci;
use disk::ide::Ide;
use env::Environment;
use schemes::file::FileScheme;
use super::config::PciConfig;
use super::common::class::*;
use super::common::subclass::*;
use super::common::programming_interface::*;
/*
use super::common::vendorid::*;
use super::common::deviceid::*;
use audio::ac97::... | if bar > 0 {
debug!(" BAR{}: {:X}", i, bar);
pci.write(i * 4 + 0x10, 0xFFFFFFFF);
let size = (0xFFFFFFFF - (pci.read(i * 4 + 0x10) & 0xFFFFFFF0)) + 1;
pci.write(i * 4 + 0x10, bar);
... | {
for bus in 0..256 {
for slot in 0..32 {
for func in 0..8 {
let mut pci = PciConfig::new(bus as u8, slot as u8, func as u8);
let id = pci.read(0);
if (id & 0xFFFF) != 0xFFFF {
let class_id = pci.read(8);
/... | identifier_body |
main.rs | // Copyright (c) 2015 Sergey "SnakE" Gromov
//
// See the file license.txt for copying permission.
//! # Radix Conversion Utility
extern crate num;
mod table;
mod convtable;
use std::{env, path};
use num::BigInt;
use convtable::ConvTable;
use std::error::Error;
use num::traits::Num;
fn main() {
let mut table ... | <'a>(s: &'a str, prefix: &str) -> Option<&'a str> {
if s.starts_with(prefix) {
Some(&s[prefix.len()..])
} else {
None
}
}
const VERSION: &'static str = env!("CARGO_PKG_VERSION");
fn usage(tool: &str) {
println!("\
Display numbers in multiple radii
(c) 2015 Sergey \"SnakE\" Gromov
Versi... | strip_prefix | identifier_name |
main.rs | // Copyright (c) 2015 Sergey "SnakE" Gromov
//
// See the file license.txt for copying permission.
//! # Radix Conversion Utility
extern crate num;
mod table;
mod convtable;
use std::{env, path};
use num::BigInt;
use convtable::ConvTable;
use std::error::Error;
use num::traits::Num;
fn main() {
let mut table ... |
const VERSION: &'static str = env!("CARGO_PKG_VERSION");
fn usage(tool: &str) {
println!("\
Display numbers in multiple radii
(c) 2015 Sergey \"SnakE\" Gromov
Version {}
Usage: {} num [num...]
num decimal, hex, octal, or binary number
decimal start with a digit
hex start with `0x`
octal st... | {
if s.starts_with(prefix) {
Some(&s[prefix.len()..])
} else {
None
}
} | identifier_body |
main.rs | // Copyright (c) 2015 Sergey "SnakE" Gromov
//
// See the file license.txt for copying permission.
//! # Radix Conversion Utility
extern crate num;
mod table;
mod convtable;
use std::{env, path};
use num::BigInt;
use convtable::ConvTable;
use std::error::Error;
use num::traits::Num;
fn main() {
let mut table ... | match BigInt::from_str_radix(&v, radix) {
Ok(x) => table.push_result(&arg, &x),
Err(e) => table.push_error(&arg, e.description()),
};
}
table.print();
}
/// Return input string without prefix if prefix matches.
fn strip_prefix<'a>(s: &'a str, prefix: &str) -> Option<&'a... | } else {
(&*arg, 10)
};
| random_line_split |
view.rs | /*!
PE view.
*/
use std::prelude::v1::*;
use std::{cmp, slice};
use crate::Result;
use super::image::*;
use super::pe::validate_headers;
use super::{Align, Pe, PeObject};
/// View into a mapped PE image.
#[derive(Copy, Clone)]
pub struct PeView<'a> {
image: &'a [u8],
}
current_target! {
impl PeView<'static> {
... | }
// Clamp to the actual image size...
file_size = cmp::min(file_size, sizeof_image);
// Zero fill the underlying file
let mut vec = vec![0u8; file_size as usize];
// Start by copying the headers
let image = self.image();
unsafe {
// Validated by constructor
let dest_headers = vec.get_unchecked_... | let mut file_size = sizeof_headers;
for section in self.section_headers() {
file_size = cmp::max(file_size, u32::wrapping_add(section.PointerToRawData, section.SizeOfRawData)); | random_line_split |
view.rs | /*!
PE view.
*/
use std::prelude::v1::*;
use std::{cmp, slice};
use crate::Result;
use super::image::*;
use super::pe::validate_headers;
use super::{Align, Pe, PeObject};
/// View into a mapped PE image.
#[derive(Copy, Clone)]
pub struct PeView<'a> {
image: &'a [u8],
}
current_target! {
impl PeView<'static> {
... |
}
vec
}
}
//----------------------------------------------------------------
unsafe impl<'a> Pe<'a> for PeView<'a> {}
unsafe impl<'a> PeObject<'a> for PeView<'a> {
fn image(&self) -> &'a [u8] {
self.image
}
fn align(&self) -> Align {
Align::Section
}
#[cfg(feature = "serde")]
fn serde_name(&self) ->... | {
dest.copy_from_slice(src);
} | conditional_block |
view.rs | /*!
PE view.
*/
use std::prelude::v1::*;
use std::{cmp, slice};
use crate::Result;
use super::image::*;
use super::pe::validate_headers;
use super::{Align, Pe, PeObject};
/// View into a mapped PE image.
#[derive(Copy, Clone)]
pub struct PeView<'a> {
image: &'a [u8],
}
current_target! {
impl PeView<'static> {
... |
}
//----------------------------------------------------------------
#[cfg(feature = "serde")]
impl<'a> serde::Serialize for PeView<'a> {
fn serialize<S: serde::Serializer>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error> {
super::pe::serialize_pe(*self, serializer)
}
}
//--------------------------... | {
"PeView"
} | identifier_body |
view.rs | /*!
PE view.
*/
use std::prelude::v1::*;
use std::{cmp, slice};
use crate::Result;
use super::image::*;
use super::pe::validate_headers;
use super::{Align, Pe, PeObject};
/// View into a mapped PE image.
#[derive(Copy, Clone)]
pub struct PeView<'a> {
image: &'a [u8],
}
current_target! {
impl PeView<'static> {
... | <S: serde::Serializer>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error> {
super::pe::serialize_pe(*self, serializer)
}
}
//----------------------------------------------------------------
#[cfg(test)]
mod tests {
use crate::Error;
use super::PeView;
#[test]
fn from_byte_slice() {
assert!(match ... | serialize | identifier_name |
xrwebglsubimage.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::codegen::Bindings::XRWebGLSubImageBinding::XRWebGLSubImageBinding::XRWebGLSubImageMetho... | fn GetImageIndex(&self) -> Option<u32> {
self.image_index
}
} | random_line_split | |
xrwebglsubimage.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::codegen::Bindings::XRWebGLSubImageBinding::XRWebGLSubImageBinding::XRWebGLSubImageMetho... | (&self) -> Option<u32> {
self.image_index
}
}
| GetImageIndex | identifier_name |
xrwebglsubimage.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::codegen::Bindings::XRWebGLSubImageBinding::XRWebGLSubImageBinding::XRWebGLSubImageMetho... |
/// https://immersive-web.github.io/layers/#dom-xrwebglsubimage-imageindex
fn GetImageIndex(&self) -> Option<u32> {
self.image_index
}
}
| {
self.depth_stencil_texture.as_deref().map(DomRoot::from_ref)
} | identifier_body |
thread.rs | use alloc::boxed::Box;
use core::mem;
use system::syscall::{sys_clone, sys_exit, sys_yield, sys_nanosleep, sys_waitpid, CLONE_VM, CLONE_FS, CLONE_FILES,
TimeSpec};
use time::Duration;
/// An owned permission to join on a thread (block on its termination).
///
/// A `JoinHandle` *detaches* the child th... |
}
/// Sleep for a duration
pub fn sleep(duration: Duration) {
let req = TimeSpec {
tv_sec: duration.as_secs() as i64,
tv_nsec: duration.subsec_nanos() as i32,
};
let mut rem = TimeSpec {
tv_sec: 0,
tv_nsec: 0,
};
let _ = sys_nanosleep(&req, &mut rem);
}
/// Sleep... | {
let mut status = 0;
match sys_waitpid(self.pid, &mut status, 0) {
Ok(_) => unsafe { *Box::from_raw(self.result_ptr) },
Err(_) => None
}
} | identifier_body |
thread.rs | use alloc::boxed::Box;
use core::mem;
use system::syscall::{sys_clone, sys_exit, sys_yield, sys_nanosleep, sys_waitpid, CLONE_VM, CLONE_FS, CLONE_FILES,
TimeSpec};
use time::Duration;
/// An owned permission to join on a thread (block on its termination).
///
/// A `JoinHandle` *detaches* the child th... | <F, T>(f: F) -> JoinHandle<T>
where F: FnOnce() -> T,
F: Send +'static,
T: Send +'static
{
let result_ptr: *mut Option<T> = Box::into_raw(box None);
//This must only be used by the child
let boxed_f = Box::new(f);
match unsafe { sys_clone(CLONE_VM | CLONE_FS | CLONE_FILES).unwra... | spawn | identifier_name |
thread.rs | use alloc::boxed::Box;
use core::mem;
use system::syscall::{sys_clone, sys_exit, sys_yield, sys_nanosleep, sys_waitpid, CLONE_VM, CLONE_FS, CLONE_FILES,
TimeSpec};
use time::Duration;
/// An owned permission to join on a thread (block on its termination).
///
/// A `JoinHandle` *detaches* the child th... | let _ = sys_nanosleep(&req, &mut rem);
}
/// Sleep for a number of milliseconds
pub fn sleep_ms(ms: u32) {
let secs = ms as u64 / 1000;
let nanos = (ms % 1000) * 1000000;
sleep(Duration::new(secs, nanos))
}
/// Spawns a new thread, returning a `JoinHandle` for it.
///
/// The join handle will implicit... | let mut rem = TimeSpec {
tv_sec: 0,
tv_nsec: 0,
};
| random_line_split |
sequence.rs | use io::fai::FaiRecord;
use sequence::*;
use std::fmt;
use std::fs::File;
use std::io::Read;
use std::io::Seek;
use std::io::SeekFrom;
use std::path::Path;
use std::path::PathBuf;
#[derive(Clone, Debug)]
pub struct FaiSequence {
record: FaiRecord,
filename: PathBuf,
}
impl FaiSequence {
pub fn new<P: AsRe... |
fn length(&self) -> usize {
self.record.length()
}
fn vec(&self) -> Vec<DnaNucleotide> {
self.subsequence(0, self.length()).vec()
}
fn subsequence(&self, offset: usize, length: usize) -> DnaSequence {
let n_lines = offset / self.record.linebases();
let n_bases = of... | }
}
impl Sequence<DnaNucleotide> for FaiSequence {
type SubsequenceType = DnaSequence; | random_line_split |
sequence.rs |
use io::fai::FaiRecord;
use sequence::*;
use std::fmt;
use std::fs::File;
use std::io::Read;
use std::io::Seek;
use std::io::SeekFrom;
use std::path::Path;
use std::path::PathBuf;
#[derive(Clone, Debug)]
pub struct FaiSequence {
record: FaiRecord,
filename: PathBuf,
}
impl FaiSequence {
pub fn new<P: AsR... |
fn vec(&self) -> Vec<DnaNucleotide> {
self.subsequence(0, self.length()).vec()
}
fn subsequence(&self, offset: usize, length: usize) -> DnaSequence {
let n_lines = offset / self.record.linebases();
let n_bases = offset - (n_lines * self.record.linebases());
let file_offset... | {
self.record.length()
} | identifier_body |
sequence.rs |
use io::fai::FaiRecord;
use sequence::*;
use std::fmt;
use std::fs::File;
use std::io::Read;
use std::io::Seek;
use std::io::SeekFrom;
use std::path::Path;
use std::path::PathBuf;
#[derive(Clone, Debug)]
pub struct | {
record: FaiRecord,
filename: PathBuf,
}
impl FaiSequence {
pub fn new<P: AsRef<Path>>(record: FaiRecord, filename: &P) -> FaiSequence {
FaiSequence {
record: record,
filename: filename.as_ref().to_path_buf(),
}
}
}
impl Sequence<DnaNucleotide> for FaiSequence... | FaiSequence | identifier_name |
non_ts_pseudo_class_list.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
* This file contains a helper macro includes all supported non-tree-structural
* pseudo-classes.
*
* FIXME... | ("focus", Focus, focus, IN_FOCUS_STATE, _),
("focus-within", FocusWithin, focusWithin, IN_FOCUS_WITHIN_STATE, _),
("hover", Hover, hover, IN_HOVER_STATE, _),
("-moz-drag-over", MozDragOver, mozDragOver, IN_DRAGOVER_STATE, _),
("target", Tar... | ("visited", Visited, visited, IN_VISITED_STATE, _),
("active", Active, active, IN_ACTIVE_STATE, _),
("checked", Checked, checked, IN_CHECKED_STATE, _),
("disabled", Disabled, disabled, IN_DISABLED_STATE, _),
("enabled", Enabled, enabled, IN... | random_line_split |
update.rs | #![feature(test)]
extern crate protocoll;
extern crate test;
use test::Bencher;
use protocoll::Map;
use std::collections::HashMap;
#[bench]
fn imperative(b: &mut Bencher) {
let sent = "a short treatise on fungi";
b.iter(|| {
let mut letters = HashMap::new();
for ch in sent.chars() {
... | let sent = "a short treatise on fungi";
b.iter(|| sent.chars().fold(HashMap::new(), |m,c| m.update_in_place(c, 0, |n| *n += 1)))
} |
#[bench]
fn in_place(b: &mut Bencher) { | random_line_split |
update.rs | #![feature(test)]
extern crate protocoll;
extern crate test;
use test::Bencher;
use protocoll::Map;
use std::collections::HashMap;
#[bench]
fn imperative(b: &mut Bencher) {
let sent = "a short treatise on fungi";
b.iter(|| {
let mut letters = HashMap::new();
for ch in sent.chars() {
... |
#[bench]
fn in_place(b: &mut Bencher) {
let sent = "a short treatise on fungi";
b.iter(|| sent.chars().fold(HashMap::new(), |m,c| m.update_in_place(c, 0, |n| *n += 1)))
}
| {
let sent = "a short treatise on fungi";
b.iter(|| sent.chars().fold(HashMap::new(), |m,c| m.update(c, |n| 1 + n.unwrap_or(0))))
} | identifier_body |
update.rs | #![feature(test)]
extern crate protocoll;
extern crate test;
use test::Bencher;
use protocoll::Map;
use std::collections::HashMap;
#[bench]
fn imperative(b: &mut Bencher) {
let sent = "a short treatise on fungi";
b.iter(|| {
let mut letters = HashMap::new();
for ch in sent.chars() {
... | (b: &mut Bencher) {
let sent = "a short treatise on fungi";
b.iter(|| sent.chars().fold(HashMap::new(), |m,c| m.update(c, |n| 1 + n.unwrap_or(0))))
}
#[bench]
fn in_place(b: &mut Bencher) {
let sent = "a short treatise on fungi";
b.iter(|| sent.chars().fold(HashMap::new(), |m,c| m.update_in_place(c, ... | functional | identifier_name |
unwind.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
unsafe {
let closure: Closure = cast::transmute(f);
let ep = rust_try(try_fn, closure.code as *c_void,
closure.env as *c_void);
if!ep.is_null() {
rtdebug!("caught {}", (*ep).exception_class);
uw::_Unwind_DeleteExc... | use libc::{c_void}; | random_line_split |
unwind.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | (code: *c_void, env: *c_void) {
unsafe {
let closure: || = cast::transmute(Closure {
code: code as *(),
env: env as *(),
});
closure();
}
}
extern {
// Rust's try-catch
... | try_fn | identifier_name |
unwind.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | }
extern "C" fn exception_cleanup(_unwind_code: uw::_Unwind_Reason_Code,
exception: *uw::_Unwind_Exception) {
rtdebug!("exception_cleanup()");
unsafe {
let _: ~uw::_Unwind_Exception = cast::transmute... | {
rtdebug!("begin_unwind()");
self.unwinding = true;
self.cause = Some(cause);
rust_fail();
// An uninlined, unmangled function upon which to slap yer breakpoints
#[inline(never)]
#[no_mangle]
fn rust_fail() -> ! {
unsafe {
l... | identifier_body |
addresses.rs | use postgres;
use ipm::PostgresReqExt;
use rustc_serialize::json::{Json, ToJson};
#[derive(ToJson)]
pub struct Address {
address_id: i32,
address: String,
postal_code: String,
city: String,
state: String,
country: String,
geospot: Json | pub fn get_by_contact_id(req: &PostgresReqExt, contact_id: i32) -> Vec<Address> {
let mut vec = Vec::new();
let conn = req.db_conn();
let stmt = conn.prepare(
"SELECT * FROM addresses a \
WHERE EXISTS(SELECT * ... | }
impl Address { | random_line_split |
addresses.rs |
use postgres;
use ipm::PostgresReqExt;
use rustc_serialize::json::{Json, ToJson};
#[derive(ToJson)]
pub struct Address {
address_id: i32,
address: String,
postal_code: String,
city: String,
state: String,
country: String,
geospot: Json
}
impl Address {
pub fn get_by_contact_id(req: &P... | (&self, req: &PostgresReqExt) -> postgres::Result<u64> {
let conn = req.db_conn();
//TODO: trigger for INSERT or UPDATE to remove duplicates.
// if address_id is 0, then INSERT else UPDATE.
conn.execute(
"INSERT INTO addresses \
VALUES($1, $2, $... | commit | identifier_name |
fuse.rs | use core::pin::Pin;
use futures_core::stream::{FusedStream, Stream};
use futures_core::task::{Context, Poll};
#[cfg(feature = "sink")]
use futures_sink::Sink;
use pin_utils::{unsafe_pinned, unsafe_unpinned};
/// Stream for the [`fuse`](super::StreamExt::fuse) method.
#[derive(Debug)]
#[must_use = "streams do nothing u... | (&self) -> (usize, Option<usize>) {
if self.done {
(0, Some(0))
} else {
self.stream.size_hint()
}
}
}
// Forwarding impl of Sink from the underlying stream
#[cfg(feature = "sink")]
impl<S: Stream + Sink<Item>, Item> Sink<Item> for Fuse<S> {
type Error = S::Error... | size_hint | identifier_name |
fuse.rs | use core::pin::Pin;
use futures_core::stream::{FusedStream, Stream};
use futures_core::task::{Context, Poll};
#[cfg(feature = "sink")]
use futures_sink::Sink;
use pin_utils::{unsafe_pinned, unsafe_unpinned};
/// Stream for the [`fuse`](super::StreamExt::fuse) method.
#[derive(Debug)]
#[must_use = "streams do nothing u... |
/// Acquires a pinned mutable reference to the underlying stream that this
/// combinator is pulling from.
///
/// Note that care must be taken to avoid tampering with the state of the
/// stream which may otherwise confuse this combinator.
pub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut ... | {
&mut self.stream
} | identifier_body |
fuse.rs | use core::pin::Pin;
use futures_core::stream::{FusedStream, Stream};
use futures_core::task::{Context, Poll};
#[cfg(feature = "sink")]
use futures_sink::Sink;
use pin_utils::{unsafe_pinned, unsafe_unpinned};
/// Stream for the [`fuse`](super::StreamExt::fuse) method.
#[derive(Debug)]
#[must_use = "streams do nothing u... | else {
self.stream.size_hint()
}
}
}
// Forwarding impl of Sink from the underlying stream
#[cfg(feature = "sink")]
impl<S: Stream + Sink<Item>, Item> Sink<Item> for Fuse<S> {
type Error = S::Error;
delegate_sink!(stream, Item);
}
| {
(0, Some(0))
} | conditional_block |
fuse.rs | use core::pin::Pin;
use futures_core::stream::{FusedStream, Stream};
use futures_core::task::{Context, Poll};
#[cfg(feature = "sink")]
use futures_sink::Sink;
use pin_utils::{unsafe_pinned, unsafe_unpinned};
/// Stream for the [`fuse`](super::StreamExt::fuse) method.
#[derive(Debug)]
#[must_use = "streams do nothing u... | impl<St> Fuse<St> {
unsafe_pinned!(stream: St);
unsafe_unpinned!(done: bool);
pub(super) fn new(stream: St) -> Fuse<St> {
Fuse { stream, done: false }
}
/// Returns whether the underlying stream has finished or not.
///
/// If this method returns `true`, then all future calls to po... | random_line_split | |
server.rs | use std::net::{TcpListener, TcpStream};
use std::io::{Read, Write};
use std::env;
use std::thread;
fn main() {
let args: Vec<String> = env::args().map(|x| x.to_string())
.collect();
let program = &args[0];
if args.len()!= 3 {
print_usage(program);
ret... | Ok(_) => { /* the operation has succeed */ }
Err(e) => {
println!("Error echoing back: {}", e);
return;
}
};
}
}
// accept connections and process them, spawning a new thread for each one
for stream ... |
// echo incoming bytes back
match stream.write(&mut buf) { | random_line_split |
server.rs | use std::net::{TcpListener, TcpStream};
use std::io::{Read, Write};
use std::env;
use std::thread;
fn main() |
fn start_server(addr: &str) {
let listener = match TcpListener::bind(addr) {
Ok(listener) => {
listener
}
Err(e) => {
println!("Error creating TCP Connection listener: {}", e);
return;
}
};
fn handle_client(mut stream: TcpStream) {
... | {
let args: Vec<String> = env::args().map(|x| x.to_string())
.collect();
let program = &args[0];
if args.len() != 3 {
print_usage(program);
return;
}
let address = &args[1];
let port = &args[2];
let connection_string = format!("{}:{}... | identifier_body |
server.rs | use std::net::{TcpListener, TcpStream};
use std::io::{Read, Write};
use std::env;
use std::thread;
fn main() {
let args: Vec<String> = env::args().map(|x| x.to_string())
.collect();
let program = &args[0];
if args.len()!= 3 {
print_usage(program);
ret... | (mut stream: TcpStream) {
let mut buf = [0u8; 128];
// we could use read_to_end into vector and then write_all
// instead of repeated read / writes but creating heap
// based vector for each connection feels like an overkill
loop {
// read some incoming bytes into buf... | handle_client | identifier_name |
server.rs | use std::net::{TcpListener, TcpStream};
use std::io::{Read, Write};
use std::env;
use std::thread;
fn main() {
let args: Vec<String> = env::args().map(|x| x.to_string())
.collect();
let program = &args[0];
if args.len()!= 3 {
print_usage(program);
ret... |
Err(e) => {
println!("Failed to accept connection: {}", e);
return;
}
}
}
}
fn print_usage(program: &str) {
println!("Usage: {} <address> <port>", program);
}
| {
thread::spawn(move|| {
// connection succeeded
handle_client(stream)
});
} | conditional_block |
p12.rs | use rand::{Rng, weak_rng};
use serialize::base64::FromBase64;
use ssl::symm::{self, encrypt};
fn | (input: &[u8], unknown: &[u8], key: &[u8]) -> Vec<u8> {
let mut data: Vec<u8> = Vec::with_capacity(input.len() + unknown.len());
data.extend_from_slice(input);
data.extend_from_slice(unknown);
encrypt(symm::Cipher::aes_128_ecb(), key, None, &data).unwrap()
}
#[test]
fn run() {
// unknown text we w... | encryption_oracle | identifier_name |
p12.rs | use rand::{Rng, weak_rng};
use serialize::base64::FromBase64;
use ssl::symm::{self, encrypt};
fn encryption_oracle(input: &[u8], unknown: &[u8], key: &[u8]) -> Vec<u8> {
let mut data: Vec<u8> = Vec::with_capacity(input.len() + unknown.len());
data.extend_from_slice(input);
data.extend_from_slice(unknown);
... | if block1 == block2 {
blocksize = i;
break;
}
i += 1;
}
// Determine ciphertext length
let len = encryption_oracle("".as_bytes(), &unknown, &key).len();
let mut ctxt_len = 0;
for i in 1..blocksize+1 {
let input = vec!['A' as u8; i];
le... | {
// unknown text we will attempt to decode with attacker controlled input
// to the encryption oracle
let unknown = "Um9sbGluJyBpbiBteSA1LjAKV2l0aCBteSByYWctdG9wIGRvd24gc28gbXkg\
aGFpciBjYW4gYmxvdwpUaGUgZ2lybGllcyBvbiBzdGFuZGJ5IHdhdmluZyBq\
dXN0IHRvIHNheSBoaQpEaWQgeW91... | identifier_body |
p12.rs | use rand::{Rng, weak_rng};
use serialize::base64::FromBase64;
use ssl::symm::{self, encrypt};
fn encryption_oracle(input: &[u8], unknown: &[u8], key: &[u8]) -> Vec<u8> {
let mut data: Vec<u8> = Vec::with_capacity(input.len() + unknown.len());
data.extend_from_slice(input);
data.extend_from_slice(unknown);
... | else {
input.push(plaintext[j as usize]);
}
}
input.push(char_guess);
}
for _ in 0..(blocksize - (i % blocksize)) - 1 {
input.push('A' as u8);
}
let out = encryption_oracle(&input, &unknown, &key);
let b... | {
input.push('A' as u8);
} | conditional_block |
p12.rs | use rand::{Rng, weak_rng};
use serialize::base64::FromBase64;
use ssl::symm::{self, encrypt};
fn encryption_oracle(input: &[u8], unknown: &[u8], key: &[u8]) -> Vec<u8> {
let mut data: Vec<u8> = Vec::with_capacity(input.len() + unknown.len());
data.extend_from_slice(input);
data.extend_from_slice(unknown);
... | let b_i = (i / blocksize) + 256;
let cipher_block = &out[b_i*blocksize..(b_i+1)*blocksize];
// search for input block with same AES ECB output
for char_guess_ in 0..255+1 {
let char_guess = char_guess_ as u8;
let j = char_guess as usize;
let guess_blo... |
let out = encryption_oracle(&input, &unknown, &key);
| random_line_split |
general_tests.rs |
#[macro_use]
extern crate ecs;
use ecs::{BuildData, ModifyData};
use ecs::{World, DataHelper};
use ecs::{Process, System};
use ecs::system::{EntityProcess, EntitySystem};
use ecs::EntityIter;
#[derive(Copy, Clone, Debug, PartialEq)]
pub struct Position
{
pub x: f32,
pub y: f32,
}
#[derive(Copy, Clone, Debug... | assert_eq!(Some(Team(4)), c.team.remove(&e));
assert!(!c.feature.has(&e));
assert!(c.feature.insert(&e, SomeFeature).is_none());
});
process!(world, print_position);
world.modify_entity(entity, |e: ModifyData<TestComponents>, c: &mut TestComponents| {
assert_eq!(Position { x:... | {
let mut world = World::<TestSystems>::new();
// Test entity builders
let entity = world.create_entity(|e: BuildData<TestComponents>, c: &mut TestComponents| {
c.position.add(&e, Position { x: 0.5, y: 0.7 });
c.team.add(&e, Team(4));
});
world.create_entity(|e: BuildData<TestCompon... | identifier_body |
general_tests.rs | #[macro_use]
extern crate ecs;
use ecs::{BuildData, ModifyData};
use ecs::{World, DataHelper};
use ecs::{Process, System};
use ecs::system::{EntityProcess, EntitySystem};
use ecs::EntityIter;
#[derive(Copy, Clone, Debug, PartialEq)]
pub struct Position
{
pub x: f32,
pub y: f32,
}
#[derive(Copy, Clone, Debug,... | )
}
}
pub struct HelloWorld(&'static str);
impl Process for HelloWorld
{
fn process(&mut self, _: &mut DataHelper<TestComponents, ()>)
{
println!("{}", self.0);
}
}
impl System for HelloWorld { type Components = TestComponents; type Services = (); }
pub struct PrintPosition;
impl E... | hello_world: HelloWorld = HelloWorld("Hello, World!"),
print_position: EntitySystem<PrintPosition> = EntitySystem::new(PrintPosition,
aspect!(<TestComponents>
all: [position, feature]
) | random_line_split |
general_tests.rs |
#[macro_use]
extern crate ecs;
use ecs::{BuildData, ModifyData};
use ecs::{World, DataHelper};
use ecs::{Process, System};
use ecs::system::{EntityProcess, EntitySystem};
use ecs::EntityIter;
#[derive(Copy, Clone, Debug, PartialEq)]
pub struct Position
{
pub x: f32,
pub y: f32,
}
#[derive(Copy, Clone, Debug... | (&mut self, _: &mut DataHelper<TestComponents, ()>)
{
println!("{}", self.0);
}
}
impl System for HelloWorld { type Components = TestComponents; type Services = (); }
pub struct PrintPosition;
impl EntityProcess for PrintPosition
{
fn process(&mut self, en: EntityIter<TestComponents>, co: &mut Data... | process | identifier_name |
htmltabledatacellelement.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::Bindings::HTMLTableDataCellElementBinding;
use dom::bindings::codegen::InheritTypes::H... |
}
impl HTMLTableDataCellElement {
fn new_inherited(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> HTMLTableDataCellElement {
HTMLTableDataCellElement {
htmltablecellelement: HTMLTableCellElement::new_inherited(HTMLTableCellElementTypeId::HTMLTableDataCellElement... | {
*self.type_id() == EventTargetTypeId::Node(NodeTypeId::Element(
ElementTypeId::HTMLElement(
HTMLElementTypeId::HTMLTableCellElement(
HTMLTableCellElementType... | identifier_body |
htmltabledatacellelement.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::Bindings::HTMLTableDataCellElementBinding;
use dom::bindings::codegen::InheritTypes::H... | }
#[allow(unrooted_must_root)]
pub fn new(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>)
-> Temporary<HTMLTableDataCellElement> {
Node::reflect_node(box HTMLTableDataCellElement::new_inherited(localName,
... | fn new_inherited(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> HTMLTableDataCellElement {
HTMLTableDataCellElement {
htmltablecellelement: HTMLTableCellElement::new_inherited(HTMLTableCellElementTypeId::HTMLTableDataCellElement,
... | random_line_split |
htmltabledatacellelement.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::Bindings::HTMLTableDataCellElementBinding;
use dom::bindings::codegen::InheritTypes::H... | (localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>)
-> Temporary<HTMLTableDataCellElement> {
Node::reflect_node(box HTMLTableDataCellElement::new_inherited(localName,
prefix,
... | new | identifier_name |
challenge1.rs | use bitwise::base64;
use bitwise::hex_rep::ToHexRep;
use challengeinfo::challenge::{Challenge, ChallengeInfo};
pub const INFO1: ChallengeInfo<'static> = ChallengeInfo {
set_number: 1,
challenge_number: 1,
title: "Convert hex to base64",
description: "",
url: "http://cryptopals.com/sets/1/challenge... | let hex_str = String::from("49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d");
base64::to_base64(&String::from_utf8(hex_str.to_hex().unwrap()).unwrap())
} | random_line_split | |
challenge1.rs | use bitwise::base64;
use bitwise::hex_rep::ToHexRep;
use challengeinfo::challenge::{Challenge, ChallengeInfo};
pub const INFO1: ChallengeInfo<'static> = ChallengeInfo {
set_number: 1,
challenge_number: 1,
title: "Convert hex to base64",
description: "",
url: "http://cryptopals.com/sets/1/challenge... | () -> String {
let hex_str = String::from("49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d");
base64::to_base64(&String::from_utf8(hex_str.to_hex().unwrap()).unwrap())
}
| execute | identifier_name |
challenge1.rs | use bitwise::base64;
use bitwise::hex_rep::ToHexRep;
use challengeinfo::challenge::{Challenge, ChallengeInfo};
pub const INFO1: ChallengeInfo<'static> = ChallengeInfo {
set_number: 1,
challenge_number: 1,
title: "Convert hex to base64",
description: "",
url: "http://cryptopals.com/sets/1/challenge... | {
let hex_str = String::from("49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d");
base64::to_base64(&String::from_utf8(hex_str.to_hex().unwrap()).unwrap())
} | identifier_body | |
import.rs | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | //~^ no `baz` in `zed`. Did you mean to use `bar`?
mod zed {
pub fn bar() { println!("bar"); }
use foo; //~ ERROR unresolved import `foo` [E0432]
//~^ no `foo` in the root
}
fn main() {
zed::foo(); //~ ERROR `foo` is private
bar();
} | // option. This file may not be copied, modified, or distributed
// except according to those terms.
use zed::bar;
use zed::baz; //~ ERROR unresolved import `zed::baz` [E0432] | random_line_split |
import.rs | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | {
zed::foo(); //~ ERROR `foo` is private
bar();
} | identifier_body | |
import.rs | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | () { println!("bar"); }
use foo; //~ ERROR unresolved import `foo` [E0432]
//~^ no `foo` in the root
}
fn main() {
zed::foo(); //~ ERROR `foo` is private
bar();
}
| bar | identifier_name |
headless.rs | extern crate glutin;
extern crate libc;
use std::ptr;
mod gl {
pub use self::Gles2 as Gl;
include!(concat!(env!("OUT_DIR"), "/test_gl_bindings.rs"));
} | use gl::types::*;
use glutin::GlContext;
#[cfg(target_os = "macos")]
#[test]
fn test_headless() {
let width: i32 = 256;
let height: i32 = 256;
let window = glutin::HeadlessRendererBuilder::new(width as u32, height as u32).build().unwrap();
unsafe { window.make_current().expect("Couldn't make window c... | random_line_split | |
headless.rs | extern crate glutin;
extern crate libc;
use std::ptr;
mod gl {
pub use self::Gles2 as Gl;
include!(concat!(env!("OUT_DIR"), "/test_gl_bindings.rs"));
}
use gl::types::*;
use glutin::GlContext;
#[cfg(target_os = "macos")]
#[test]
fn | () {
let width: i32 = 256;
let height: i32 = 256;
let window = glutin::HeadlessRendererBuilder::new(width as u32, height as u32).build().unwrap();
unsafe { window.make_current().expect("Couldn't make window current") };
let gl = gl::Gl::load_with(|symbol| window.get_proc_address(symbol) as *const ... | test_headless | identifier_name |
headless.rs | extern crate glutin;
extern crate libc;
use std::ptr;
mod gl {
pub use self::Gles2 as Gl;
include!(concat!(env!("OUT_DIR"), "/test_gl_bindings.rs"));
}
use gl::types::*;
use glutin::GlContext;
#[cfg(target_os = "macos")]
#[test]
fn test_headless() | gl.FramebufferTexture2D(gl::FRAMEBUFFER, gl::COLOR_ATTACHMENT0, gl::TEXTURE_2D, texture, 0);
let status = gl.CheckFramebufferStatus(gl::FRAMEBUFFER);
if status!= gl::FRAMEBUFFER_COMPLETE {
panic!("Error while creating the framebuffer");
}
gl.ClearColor(0.0, 1.0, 0.0, 1... | {
let width: i32 = 256;
let height: i32 = 256;
let window = glutin::HeadlessRendererBuilder::new(width as u32, height as u32).build().unwrap();
unsafe { window.make_current().expect("Couldn't make window current") };
let gl = gl::Gl::load_with(|symbol| window.get_proc_address(symbol) as *const _);... | identifier_body |
headless.rs | extern crate glutin;
extern crate libc;
use std::ptr;
mod gl {
pub use self::Gles2 as Gl;
include!(concat!(env!("OUT_DIR"), "/test_gl_bindings.rs"));
}
use gl::types::*;
use glutin::GlContext;
#[cfg(target_os = "macos")]
#[test]
fn test_headless() {
let width: i32 = 256;
let height: i32 = 256;
le... |
gl.ClearColor(0.0, 1.0, 0.0, 1.0);
gl.Clear(gl::COLOR_BUFFER_BIT);
gl.Enable(gl::SCISSOR_TEST);
gl.Scissor(1, 0, 1, 1);
gl.ClearColor(1.0, 0.0, 0.0, 1.0);
gl.Clear(gl::COLOR_BUFFER_BIT);
let mut values: Vec<u8> = vec![0;(width*height*4) as usize];
gl.Re... | {
panic!("Error while creating the framebuffer");
} | conditional_block |
main.rs | #![feature(mpsc_select)]
extern crate time;
use std::thread;
use std::sync::mpsc;
use std::sync::mpsc::{SyncSender, Receiver};
use std::sync::mpsc::Select;
use std::io::prelude::*;
use std::fs::File;
use std::vec::Vec;
use time::PreciseTime;
struct | {
writer : i32,
n : i32,
}
fn writer(out : SyncSender<StressedPacket>, writer : i32, writes : i32) {
for i in 0..writes {
out.send(StressedPacket{writer : writer, n : i}).unwrap();
}
}
fn save_results(N : usize, results : Vec<u64>) {
let mut buffer = File::create(format!("st-rust-{}.csv",... | StressedPacket | identifier_name |
main.rs | #![feature(mpsc_select)]
extern crate time;
use std::thread;
use std::sync::mpsc;
use std::sync::mpsc::{SyncSender, Receiver};
use std::sync::mpsc::Select;
use std::io::prelude::*;
use std::fs::File;
use std::vec::Vec;
use time::PreciseTime;
struct StressedPacket {
writer : i32,
n : i32,
}
fn writer(out : S... |
fn save_results(N : usize, results : Vec<u64>) {
let mut buffer = File::create(format!("st-rust-{}.csv", N)).unwrap();
for r in results {
write!(buffer, "{}\n", r);
}
buffer.flush();
}
fn do_select1(in0 : &Receiver<StressedPacket>) {
select! {
_ = in0.recv() => println!("")
}
... | {
for i in 0..writes {
out.send(StressedPacket{writer : writer, n : i}).unwrap();
}
} | identifier_body |
main.rs | #![feature(mpsc_select)]
extern crate time;
use std::thread;
use std::sync::mpsc;
use std::sync::mpsc::{SyncSender, Receiver};
use std::sync::mpsc::Select;
use std::io::prelude::*;
use std::fs::File;
use std::vec::Vec;
use time::PreciseTime;
struct StressedPacket {
writer : i32,
n : i32,
}
fn writer(out : S... | }
}
fn do_select(N : i32, input : &Vec<Receiver<StressedPacket>>) {
match N {
1 => do_select1(&input[0]),
2 => do_select2(&input[0], &input[1]),
4 => do_select4(&input[0], &input[1], &input[2], &input[3]),
8 => do_select8(&input[0], &input[1], &input[2], &input[3], &input[4], &in... | _ = in5.recv() => (),
_ = in6.recv() => (),
_ = in7.recv() => () | random_line_split |
main.rs | // Copyright 2013 The GLFW-RS Developers. For a full listing of the authors,
// refer to the AUTHORS file at the top-level directory of this distribution.
//
// 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... |
window.set_key_callback(~KeyContext);
window.set_char_callback(~CharContext);
window.set_mouse_button_callback(~MouseButtonContext);
window.set_cursor_pos_callback(~CursorPosContext);
window.set_cursor_enter_callback(~CursorEnterContext);
window.set_scroll_callback(~Scro... | window.set_focus_callback(~WindowFocusContext);
window.set_iconify_callback(~WindowIconifyContext);
window.set_framebuffer_size_callback(~FramebufferSizeContext); | random_line_split |
main.rs | // Copyright 2013 The GLFW-RS Developers. For a full listing of the authors,
// refer to the AUTHORS file at the top-level directory of this distribution.
//
// 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... |
}
struct FramebufferSizeContext;
impl glfw::FramebufferSizeCallback for FramebufferSizeContext {
fn call(&self, _: &glfw::Window, width: i32, height: i32) {
println!("Framebuffer size: {} {}", width, height);
}
}
struct KeyContext;
impl glfw::KeyCallback for KeyContext {
fn call(&self, window: &g... | {
if iconified { println("Window was minimised"); }
else { println("Window was maximised."); }
} | identifier_body |
main.rs | // Copyright 2013 The GLFW-RS Developers. For a full listing of the authors,
// refer to the AUTHORS file at the top-level directory of this distribution.
//
// 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... | (&self, _: glfw::Error, description: ~str) {
println!("GLFW Error: {:s}", description);
}
}
struct WindowPosContext;
impl glfw::WindowPosCallback for WindowPosContext {
fn call(&self, window: &glfw::Window, x: i32, y: i32) {
window.set_title(format!("Window pos: ({}, {})", x, y));
}
}
stru... | call | identifier_name |
main.rs | // Copyright 2013 The GLFW-RS Developers. For a full listing of the authors,
// refer to the AUTHORS file at the top-level directory of this distribution.
//
// 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... |
}
}
struct ScrollContext;
impl glfw::ScrollCallback for ScrollContext {
fn call(&self, window: &glfw::Window, x: f64, y: f64) {
window.set_title(format!("Scroll offset: ({}, {})", x, y));
}
}
| { println("Cursor left window."); } | conditional_block |
accept_language.rs | use header::{Language, QualityItem};
header! {
#[doc="`Accept-Language` header, defined in"]
#[doc="[RFC7231](http://tools.ietf.org/html/rfc7231#section-5.3.5)"]
#[doc=""]
#[doc="The `Accept-Language` header field can be used by user agents to"]
#[doc="indicate the set of natural languages that are... | #[doc="* `da, en-gb;q=0.8, en;q=0.7`"]
#[doc="* `en-us;q=1.0, en;q=0.5, fr`"]
(AcceptLanguage, "Accept-Language") => (QualityItem<Language>)+
test_accept_language {
// From the RFC
test_header!(test1, vec![b"da, en-gb;q=0.8, en;q=0.7"]);
// Own test
test_header!(
... | #[doc="language-range = <language-range, see [RFC4647], Section 2.1>"]
#[doc="```"]
#[doc=""]
#[doc="# Example values"] | random_line_split |
manticore_protocol_cerberus_GetCert__req_to_wire.rs | // Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
//!! DO NOT EDIT!!
// To regenerate this file, run `fuzz/generate_proto_tests.py`.
#![no_main]
#![allow(non_snake_case)]
use libfuzzer_sys::fuzz_target;
use manticore... | let _ = Req::borrow(&data).to_wire(&mut &mut out[..]);
}); | random_line_split | |
boxed.rs | // Copyright 2012-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-MI... | pub fn downcast<T: Any>(self) -> Result<Box<T>, Box<Any>> {
if self.is::<T>() {
unsafe {
// Get the raw representation of the trait object
let raw = Box::into_raw(self);
let to: TraitObject =
mem::transmute::<*mut Any, TraitObje... | impl Box<Any> {
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
/// Attempt to downcast the box to a concrete type. | random_line_split |
boxed.rs | // Copyright 2012-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-MI... |
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: Clone> Clone for Box<T> {
/// Returns a new box with a `clone()` of this box's contents.
///
/// # Examples
///
/// ```
/// let x = Box::new(5);
/// let y = x.clone();
/// ```
#[inline]
fn clone(&self) -> Box<T> { box {(**... | { Box::<[T; 0]>::new([]) } | identifier_body |
boxed.rs | // Copyright 2012-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-MI... | else {
Err(self)
}
}
}
impl Box<Any + Send> {
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
/// Attempt to downcast the box to a concrete type.
pub fn downcast<T: Any>(self) -> Result<Box<T>, Box<Any + Send>> {
<Box<Any>>::downcast(self).map_err(|s| unsafe {
... | {
unsafe {
// Get the raw representation of the trait object
let raw = Box::into_raw(self);
let to: TraitObject =
mem::transmute::<*mut Any, TraitObject>(raw);
// Extract the data pointer
Ok(Box::from_raw(to... | conditional_block |
boxed.rs | // Copyright 2012-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-MI... | <T: Any>(self) -> Result<Box<T>, Box<Any + Send>> {
<Box<Any>>::downcast(self).map_err(|s| unsafe {
// reapply the Send marker
mem::transmute::<Box<Any>, Box<Any + Send>>(s)
})
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: fmt::Display +?Sized> fmt::Display for B... | downcast | identifier_name |
gash.rs | //
// gash.rs
//
// Starting code for PS2
// Running on Rust 0.9
//
// University of Virginia - cs4414 Spring 2014
// Weilin Xu, David Evans
// Version 0.4
//
extern mod extra;
use std::{io, run, os};
use std::io::buffered::BufferedReader;
use std::io::stdin;
use extra::getopts;
use std::io::File;
use std::io::signal... |
fn run_cmdline(&mut self, cmd_line: &str, output: bool) -> ~str {
let mut argv: ~[~str] =
cmd_line.split(' ').filter_map(|x| if x!= "" { Some(x.to_owned()) } else { None }).to_owned_vec();
let length = argv.len()-1;
if argv[length] == ~"&" {
argv.remove(length);
let pro... | }
~"fine"
} | random_line_split |
gash.rs | //
// gash.rs
//
// Starting code for PS2
// Running on Rust 0.9
//
// University of Virginia - cs4414 Spring 2014
// Weilin Xu, David Evans
// Version 0.4
//
extern mod extra;
use std::{io, run, os};
use std::io::buffered::BufferedReader;
use std::io::stdin;
use extra::getopts;
use std::io::File;
use std::io::signal... |
fn run_cd(&mut self, cmd_line: &str) {
let mut argv: ~[~str] =
cmd_line.split(' ').filter_map(|x| if x!= "" { Some(x.to_owned()) } else { None }).to_owned_vec();
if argv.len() > 0 {
if argv.len() == 1 {
self.go_to_home_dir();
return ;
... | {
if output == false{
for i in range(0, self.log.len()) {
println!("{}", self.log[i]);
}
return ~"none";
}
else {
let mut out: ~str = ~"";
for i in range(0, self.log.len()){
out = out + self.log[i].to_owned();
}
return out;
}
} | identifier_body |
gash.rs | //
// gash.rs
//
// Starting code for PS2
// Running on Rust 0.9
//
// University of Virginia - cs4414 Spring 2014
// Weilin Xu, David Evans
// Version 0.4
//
extern mod extra;
use std::{io, run, os};
use std::io::buffered::BufferedReader;
use std::io::stdin;
use extra::getopts;
use std::io::File;
use std::io::signal... | (&mut self, cmd_line : &str, output: bool) -> ~str{
let program = cmd_line.splitn(' ', 1).nth(0).expect("no program"); // get command
match program {
"" => { return ~"continue"; }
"exit" => { return ~"return"; }
"history" => {
... | find_prog | identifier_name |
gash.rs | //
// gash.rs
//
// Starting code for PS2
// Running on Rust 0.9
//
// University of Virginia - cs4414 Spring 2014
// Weilin Xu, David Evans
// Version 0.4
//
extern mod extra;
use std::{io, run, os};
use std::io::buffered::BufferedReader;
use std::io::stdin;
use extra::getopts;
use std::io::File;
use std::io::signal... |
}
fn go_to_home_dir(&mut self){
match std::os::homedir() {
Some(path) => {
std::os::change_dir(&path);
}
None => {
println("$HOME is not set");
}
}
}
}
fn write_file(filename: ~str, message: ~... | {
println("Invalid input");
} | conditional_block |
issue-10806.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... | 3
}
pub fn bar() -> int {
4
}
pub mod baz {
use {foo, bar};
pub fn quux() -> int {
foo() + bar()
}
}
pub mod grault {
use {foo};
pub fn garply() -> int {
foo()
}
}
pub mod waldo {
use {};
pub fn plugh() -> int {
0
}
}
pub fn main() {
let _x = b... | pub fn foo() -> int { | random_line_split |
issue-10806.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... | () -> int {
foo() + bar()
}
}
pub mod grault {
use {foo};
pub fn garply() -> int {
foo()
}
}
pub mod waldo {
use {};
pub fn plugh() -> int {
0
}
}
pub fn main() {
let _x = baz::quux();
let _y = grault::garply();
let _z = waldo::plugh();
}
| quux | identifier_name |
issue-10806.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... |
}
pub mod waldo {
use {};
pub fn plugh() -> int {
0
}
}
pub fn main() {
let _x = baz::quux();
let _y = grault::garply();
let _z = waldo::plugh();
}
| {
foo()
} | identifier_body |
mod.rs | /*
copyright: (c) 2013-2018 by Blockstack PBC, a public benefit corporation.
This file is part of Blockstack.
Blockstack is free software. You may redistribute 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... |
fn description(&self) -> &str {
match *self {
HexError::BadLength(_) => "sha256d hex string non-64 length",
HexError::BadCharacter(_) => "sha256d bad hex character"
}
}
}
| { None } | identifier_body |
mod.rs | /*
copyright: (c) 2013-2018 by Blockstack PBC, a public benefit corporation.
This file is part of Blockstack.
Blockstack is free software. You may redistribute 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... | pub mod strings;
pub mod vrf;
use std::time;
use std::thread;
use std::time::{SystemTime, UNIX_EPOCH};
use std::fmt;
use std::error;
pub fn get_epoch_time_secs() -> u64 {
let start = SystemTime::now();
let since_the_epoch = start.duration_since(UNIX_EPOCH)
.expect("Time went backwards");
return sin... | random_line_split | |
mod.rs | /*
copyright: (c) 2013-2018 by Blockstack PBC, a public benefit corporation.
This file is part of Blockstack.
Blockstack is free software. You may redistribute 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... | (&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
HexError::BadLength(n) => write!(f, "bad length {} for sha256d hex string", n),
HexError::BadCharacter(c) => write!(f, "bad character {} in sha256d hex string", c)
}
}
}
impl error::Error for HexError {
fn ca... | fmt | identifier_name |
parsing.rs | //! Utility functions for Header implementations.
use std::str;
use std::fmt::{self, Display};
/// Reads a single raw string when parsing a header
pub fn from_one_raw_str<T: str::FromStr>(raw: &[Vec<u8>]) -> Option<T> {
if raw.len()!= 1 {
return None;
}
// we JUST checked that raw.len() == 1, so r... | }
None
}
/// Reads a comma-delimited raw header into a Vec.
#[inline]
pub fn from_comma_delimited<T: str::FromStr>(raw: &[Vec<u8>]) -> Option<Vec<T>> {
if raw.len()!= 1 {
return None;
}
// we JUST checked that raw.len() == 1, so raw[0] WILL exist.
from_one_comma_delimited(& unsafe { raw... | random_line_split | |
parsing.rs | //! Utility functions for Header implementations.
use std::str;
use std::fmt::{self, Display};
/// Reads a single raw string when parsing a header
pub fn from_one_raw_str<T: str::FromStr>(raw: &[Vec<u8>]) -> Option<T> {
if raw.len()!= 1 {
return None;
}
// we JUST checked that raw.len() == 1, so r... |
/// Reads a comma-delimited raw string into a Vec.
pub fn from_one_comma_delimited<T: str::FromStr>(raw: &[u8]) -> Option<Vec<T>> {
match str::from_utf8(raw) {
Ok(s) => {
Some(s
.split(',')
.filter_map(|x| match x.trim() {
"" => None,
... | {
if raw.len() != 1 {
return None;
}
// we JUST checked that raw.len() == 1, so raw[0] WILL exist.
from_one_comma_delimited(& unsafe { raw.get_unchecked(0) }[..])
} | identifier_body |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.