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 |
|---|---|---|---|---|
mod.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
mod heartbeat;
mod lsp_notification_dispatch;
mod lsp_request_dispatch;
mod lsp_state;
mod lsp_state_resources;
mod task_queue;
... | <
TPerfLogger: PerfLogger +'static,
TSchemaDocumentation: SchemaDocumentation +'static,
>(
connection: Connection,
mut config: Config,
_params: InitializeParams,
perf_logger: Arc<TPerfLogger>,
extra_data_provider: Box<dyn LSPExtraDataProvider + Send + Sync>,
schema_documentation_loader: ... | run | identifier_name |
mod.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
mod heartbeat;
mod lsp_notification_dispatch;
mod lsp_request_dispatch;
mod lsp_state;
mod lsp_state_resources;
mod task_queue;
... |
Task::InboundMessage(Message::Response(_)) => {
// TODO: handle response from the client -> cancel message, etc
}
}
}
}
fn handle_request<TPerfLogger: PerfLogger +'static, TSchemaDocumentation: SchemaDocumentation>(
lsp_state: Arc<LSPState<TPerfLogger, TSchemaDo... | {
handle_lsp_state_tasks(state, lsp_task);
} | conditional_block |
lib.rs | // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any la... | //! ```
#[macro_use]
extern crate log;
extern crate env_logger;
extern crate rand;
extern crate ethcore_util as util;
extern crate ethcore_rpc as rpc;
extern crate ethcore_io as io;
extern crate jsonrpc_core;
extern crate ws;
extern crate ethcore_devtools as devtools;
mod authcode_store;
mod ws_server;
/// Exporte... | //! let io = Arc::new(IoHandler::new().into());
//! let event_loop = RpcEventLoop::spawn();
//! let _server = ServerBuilder::new(queue, "/tmp/authcodes".into())
//! .start("127.0.0.1:8084".parse().unwrap(), event_loop.handler(io));
//! } | random_line_split |
lib.rs | //! A fast, low-level IO library for Rust focusing on non-blocking APIs, event
//! notification, and other useful utilities for building high performance IO
//! apps.
//!
//! # Goals
//!
//! * Fast - minimal overhead over the equivalent OS facilities (epoll, kqueue, etc...)
//! * Zero allocations
//! * A scalable readi... | //! type Message = ();
//!
//! fn ready(&mut self, event_loop: &mut EventLoop<MyHandler>, token: Token, _: EventSet) {
//! match token {
//! SERVER => {
//! let MyHandler(ref mut server) = *self;
//! // Accept and drop the socket immediately, this will close
/... | //! impl Handler for MyHandler {
//! type Timeout = (); | random_line_split |
base64.rs | #![feature(test)]
extern crate test;
extern crate rustc_serialize;
use rustc_serialize::base64::{FromBase64, ToBase64, STANDARD};
use test::Bencher;
#[bench]
fn bench_to_base64(b: &mut Bencher) {
let s = "γ€γγγγγγ γγͺγγ«γ² γ―γ«γ¨γΏγ¬γ½ γγγγ©γ \
γ¦γ°γγͺγ―γ€γ γ±γγ³γ¨γ γ’γ΅γγ¦γ‘γγ· γ±γγ’γ»γΉγ³";
b.iter(|| {
s.as_bytes(... | γ¦γ°γγͺγ―γ€γ γ±γγ³γ¨γ γ’γ΅γγ¦γ‘γγ· γ±γγ’γ»γΉγ³";
let sb = s.as_bytes().to_base64(STANDARD);
b.iter(|| {
sb.from_base64().unwrap();
});
b.bytes = sb.len() as u64;
}
#[bench]
fn bench_to_base64_large(b: &mut Bencher) {
let s: Vec<_> = (0..10000).map(|i| ((i as u32 * 12345) % 256) as u8).collect()... | #[bench]
fn bench_from_base64(b: &mut Bencher) {
let s = "γ€γγγγγγ γγͺγγ«γ² γ―γ«γ¨γΏγ¬γ½ γγγγ©γ \ | random_line_split |
base64.rs | #![feature(test)]
extern crate test;
extern crate rustc_serialize;
use rustc_serialize::base64::{FromBase64, ToBase64, STANDARD};
use test::Bencher;
#[bench]
fn | (b: &mut Bencher) {
let s = "γ€γγγγγγ γγͺγγ«γ² γ―γ«γ¨γΏγ¬γ½ γγγγ©γ \
γ¦γ°γγͺγ―γ€γ γ±γγ³γ¨γ γ’γ΅γγ¦γ‘γγ· γ±γγ’γ»γΉγ³";
b.iter(|| {
s.as_bytes().to_base64(STANDARD);
});
b.bytes = s.len() as u64;
}
#[bench]
fn bench_from_base64(b: &mut Bencher) {
let s = "γ€γγγγγγ γγͺγγ«γ² γ―γ«γ¨γΏγ¬γ½ γγγγ©γ \
γ¦γ°γγͺγ―γ€γ γ±γγ³... | bench_to_base64 | identifier_name |
base64.rs | #![feature(test)]
extern crate test;
extern crate rustc_serialize;
use rustc_serialize::base64::{FromBase64, ToBase64, STANDARD};
use test::Bencher;
#[bench]
fn bench_to_base64(b: &mut Bencher) {
let s = "γ€γγγγγγ γγͺγγ«γ² γ―γ«γ¨γΏγ¬γ½ γγγγ©γ \
γ¦γ°γγͺγ―γ€γ γ±γγ³γ¨γ γ’γ΅γγ¦γ‘γγ· γ±γγ’γ»γΉγ³";
b.iter(|| {
s.as_bytes(... | );
b.bytes = s.len() as u64;
}
#[bench]
fn bench_from_base64_large(b: &mut Bencher) {
let s: Vec<_> = (0..10000).map(|i| ((i as u32 * 12345) % 256) as u8).collect();
let sb = s.to_base64(STANDARD);
b.iter(|| {
sb.from_base64().unwrap();
});
b.bytes = sb.len() as u64;
}
| sb = s.as_bytes().to_base64(STANDARD);
b.iter(|| {
sb.from_base64().unwrap();
});
b.bytes = sb.len() as u64;
}
#[bench]
fn bench_to_base64_large(b: &mut Bencher) {
let s: Vec<_> = (0..10000).map(|i| ((i as u32 * 12345) % 256) as u8).collect();
b.iter(|| {
s.to_base64(STANDARD);
... | identifier_body |
jmethodid.rs | use std::marker::PhantomData;
use sys::jmethodID;
/// Wrapper around `sys::jmethodid` that adds a lifetime. This prevents it from
/// outliving the context in which it was acquired and getting GC'd out from
/// under us. It matches C's representation of the raw pointer, so it can be
/// used in any of the extern func... |
impl<'a> JMethodID<'a> {
/// Unwrap to the internal jni type.
pub fn into_inner(self) -> jmethodID {
self.internal
}
} | }
}
} | random_line_split |
jmethodid.rs | use std::marker::PhantomData;
use sys::jmethodID;
/// Wrapper around `sys::jmethodid` that adds a lifetime. This prevents it from
/// outliving the context in which it was acquired and getting GC'd out from
/// under us. It matches C's representation of the raw pointer, so it can be
/// used in any of the extern func... | (self) -> jmethodID {
self.internal
}
}
| into_inner | identifier_name |
jmethodid.rs | use std::marker::PhantomData;
use sys::jmethodID;
/// Wrapper around `sys::jmethodid` that adds a lifetime. This prevents it from
/// outliving the context in which it was acquired and getting GC'd out from
/// under us. It matches C's representation of the raw pointer, so it can be
/// used in any of the extern func... |
}
| {
self.internal
} | identifier_body |
error.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 std::error;
use std::fmt;
use svgdom;
/// List of all errors.
#[derive(Debug)]
pub enum | {
/// Only `svg` and `svgz` suffixes are supported.
InvalidFileSuffix,
/// Failed to open the provided file.
FileOpenFailed,
/// Only UTF-8 content are supported.
NotAnUtf8Str,
/// Compressed SVG must use the GZip algorithm.
MalformedGZip,
/// SVG doesn't have a valid size.
... | Error | identifier_name |
error.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 std::error;
use std::fmt;
use svgdom;
/// List of all errors.
#[derive(Debug)]
pub enum Error {
/// Only `s... |
Error::FileOpenFailed => {
write!(f, "failed to open the provided file")
}
Error::NotAnUtf8Str => {
write!(f, "provided data has not an UTF-8 encoding")
}
Error::MalformedGZip => {
write!(f, "provided data has a... | {
write!(f, "invalid file suffix")
} | conditional_block |
error.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 std::error;
use std::fmt;
use svgdom;
/// List of all errors.
#[derive(Debug)]
pub enum Error {
/// Only `s... | /// Failed to open the provided file.
FileOpenFailed,
/// Only UTF-8 content are supported.
NotAnUtf8Str,
/// Compressed SVG must use the GZip algorithm.
MalformedGZip,
/// SVG doesn't have a valid size.
///
/// Occurs when width and/or height are <= 0.
///
/// Also occurs... | random_line_split | |
mod.rs | use serde::{Deserialize, Serialize};
use std::error::Error;
use std::fs::File;
use std::path::Path;
#[derive(Serialize, Deserialize)]
pub struct Database {
pub repository: String,
}
#[derive(Serialize, Deserialize)]
pub struct | {
pub port: u16,
pub address: String,
pub hostname: String,
}
#[derive(Serialize, Deserialize)]
pub struct Display {
pub width: u32,
pub height: u32,
}
#[derive(Serialize, Deserialize)]
pub struct Poetry {
pub font: String,
pub speed: f32,
}
#[derive(Serialize, Deserialize)]
pub struct E... | Server | identifier_name |
mod.rs | use serde::{Deserialize, Serialize};
use std::error::Error;
use std::fs::File;
use std::path::Path;
#[derive(Serialize, Deserialize)]
pub struct Database {
pub repository: String,
}
#[derive(Serialize, Deserialize)]
pub struct Server {
pub port: u16,
pub address: String,
pub hostname: String,
}
#[der... | #[derive(Serialize, Deserialize, Clone)]
pub struct Mqtt {
pub server: String,
pub port: Option<u16>,
pub username: Option<String>,
pub password: Option<String>,
pub topic: String,
}
fn default_fps() -> u32 {
60
}
#[derive(Serialize, Deserialize)]
pub struct Config {
pub logconfig: String,... | #[serde(default = "default_fps")]
pub fps: u32,
}
| random_line_split |
constants.rs | /// Ο <https://oeis.org/A000796>
pub const PI: f64 =
3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214;
/// sqrt(2) <https://oeis.org/A002193>
pub const SQRT_2: f64 =
1.4142135623730950488016887242096980785696718753769480731766797379907324784621070388503... | pub const SQRT_2_BY_3: f64 =
0.816496580927726032732428024901963797321982493552223376144230855750320125819105008846619811034880078272864f64;
/// sqt(3/2) <https://oeis.org/A115754>
pub const SQRT_3_BY_2: f64 =
1.22474487139158904909864203735294569598297374032833506421634628362548018872865751326992971655232011f... | pub const SQRT_6: f64 =
2.44948974278317809819728407470589139196594748065667012843269256725096037745731502653985943310464023f64;
/// sqrt(2/3) <https://oeis.org/A157697> | random_line_split |
shuffle_split.rs | //! Validation via repeated random shuffling
//! of the data and splitting into a training and test set.
//!
//! # Examples
//!
//! ```
//! use rustlearn::prelude::*;
//! use rustlearn::datasets::iris;
//! use rustlearn::cross_validation::ShuffleSplit;
//!
//!
//! let (X, y) = iris::load_data();
//!
//! let num_splits ... | else {
None
};
self.iter += 1;
ret
}
}
#[cfg(test)]
mod tests {
use super::*;
extern crate rand;
use rand::{SeedableRng, StdRng};
#[test]
fn iteration() {
let split = ShuffleSplit::new(100, 4, 0.2);
let mut count = 0;
for _ in s... | {
let split_idx: usize = (self.n as f32 * (1.0 - self.test_size)).floor() as usize;
let shuffled_indices = self.get_shuffled_indices();
let (train, test) = shuffled_indices.split_at(split_idx);
Some((train.to_owned(), test.to_owned()))
} | conditional_block |
shuffle_split.rs | //! Validation via repeated random shuffling
//! of the data and splitting into a training and test set.
//!
//! # Examples
//!
//! ```
//! use rustlearn::prelude::*;
//! use rustlearn::datasets::iris;
//! use rustlearn::cross_validation::ShuffleSplit;
//!
//!
//! let (X, y) = iris::load_data();
//!
//! let num_splits ... | let set2 = split2.collect::<Vec<_>>();
assert!(set1[0].0 == set2[0].0);
}
} | let set1 = split1.collect::<Vec<_>>(); | random_line_split |
shuffle_split.rs | //! Validation via repeated random shuffling
//! of the data and splitting into a training and test set.
//!
//! # Examples
//!
//! ```
//! use rustlearn::prelude::*;
//! use rustlearn::datasets::iris;
//! use rustlearn::cross_validation::ShuffleSplit;
//!
//!
//! let (X, y) = iris::load_data();
//!
//! let num_splits ... | (&mut self) -> Option<(Vec<usize>, Vec<usize>)> {
let ret = if self.iter < self.n_iter {
let split_idx: usize = (self.n as f32 * (1.0 - self.test_size)).floor() as usize;
let shuffled_indices = self.get_shuffled_indices();
let (train, test) = shuffled_indices.split_at(split_... | next | identifier_name |
shuffle_split.rs | //! Validation via repeated random shuffling
//! of the data and splitting into a training and test set.
//!
//! # Examples
//!
//! ```
//! use rustlearn::prelude::*;
//! use rustlearn::datasets::iris;
//! use rustlearn::cross_validation::ShuffleSplit;
//!
//!
//! let (X, y) = iris::load_data();
//!
//! let num_splits ... |
fn get_shuffled_indices(&mut self) -> Vec<usize> {
let mut indices = (0..self.n).collect::<Vec<usize>>();
self.rng.shuffle(&mut indices);
indices
}
}
impl Iterator for ShuffleSplit {
type Item = (Vec<usize>, Vec<usize>);
fn next(&mut self) -> Option<(Vec<usize>, Vec<usize>)>... | {
self.rng = rng;
} | identifier_body |
sieve.rs | extern crate sieve;
use sieve::*;
#[test]
fn limit_lower_than_the_first_prime() {
assert_eq!(sieve::primes_up_to(1), []);
}
#[test]
fn limit_is_the_first_prime() {
assert_eq!(sieve::primes_up_to(2), [2]);
}
#[test]
fn primes_up_to_10() {
assert_eq!(sieve::primes_up_to(10), [2, 3, 5, 7]);
}
#[test]
fn ... | () {
let expected = vec![2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67,
71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149,
151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229,
... | limit_of_1000 | identifier_name |
sieve.rs | extern crate sieve;
use sieve::*;
#[test]
fn limit_lower_than_the_first_prime() {
assert_eq!(sieve::primes_up_to(1), []);
}
#[test]
fn limit_is_the_first_prime() {
assert_eq!(sieve::primes_up_to(2), [2]);
}
| fn primes_up_to_10() {
assert_eq!(sieve::primes_up_to(10), [2, 3, 5, 7]);
}
#[test]
fn limit_is_prime() {
assert_eq!(sieve::primes_up_to(13), [2, 3, 5, 7, 11, 13]);
}
#[test]
fn limit_of_1000() {
let expected = vec![2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67,
... | #[test] | random_line_split |
sieve.rs | extern crate sieve;
use sieve::*;
#[test]
fn limit_lower_than_the_first_prime() {
assert_eq!(sieve::primes_up_to(1), []);
}
#[test]
fn limit_is_the_first_prime() {
assert_eq!(sieve::primes_up_to(2), [2]);
}
#[test]
fn primes_up_to_10() {
assert_eq!(sieve::primes_up_to(10), [2, 3, 5, 7]);
}
#[test]
fn ... |
#[test]
fn limit_of_1000() {
let expected = vec![2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67,
71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149,
151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 2... | {
assert_eq!(sieve::primes_up_to(13), [2, 3, 5, 7, 11, 13]);
} | identifier_body |
load.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... | self.reader.read_plugin_metadata(vi);
self.plugins.macros.push(ExportedMacros {
crate_name: name,
macros: macros,
});
match (lib, registrar_symbol) {
(Some(lib), Some(symbol))
... | {
match vi.node {
ast::ViewItemExternCrate(name, _, _) => {
let mut plugin_phase = false;
for attr in vi.attrs.iter().filter(|a| a.check_name("phase")) {
let phases = attr.meta_item_list().unwrap_or(&[]);
if attr::contains_name... | identifier_body |
load.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... |
return plugins;
}
// note that macros aren't expanded yet, and therefore macros can't add plugins.
impl<'a, 'v> Visitor<'v> for PluginLoader<'a> {
fn visit_view_item(&mut self, vi: &ast::ViewItem) {
match vi.node {
ast::ViewItemExternCrate(name, _, _) => {
let mut plugin_ph... | }
None => ()
} | random_line_split |
load.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... | {
/// Source code of macros exported by the crate.
pub macros: Vec<String>,
/// Path to the shared library file.
pub lib: Option<Path>,
/// Symbol name of the plugin registrar function.
pub registrar_symbol: Option<String>,
}
/// Pointer to a registrar function.
pub type PluginRegistrarFun =
... | PluginMetadata | identifier_name |
io.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... | (b: &mut Bencher) {
do_bench_seekable_mem_writer(b, 1, 0)
}
#[bench]
fn bench_seekable_mem_writer_001_0010(b: &mut Bencher) {
do_bench_seekable_mem_writer(b, 1, 10)
}
#[bench]
fn bench_seekable_mem_writer_001_0100(b: &mut Bencher) {
do_bench_seekable_mem_writer(b, 1, 10... | bench_seekable_mem_writer_001_0000 | identifier_name |
io.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... | // currently are
let difference = self.pos as i64 - self.buf.len() as i64;
if difference > 0 {
self.buf.extend(repeat(0).take(difference as uint));
}
// Figure out what bytes will be used to overwrite what's currently
// there (lef... | random_line_split | |
io.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... |
#[bench]
fn bench_seekable_mem_writer_001_0000(b: &mut Bencher) {
do_bench_seekable_mem_writer(b, 1, 0)
}
#[bench]
fn bench_seekable_mem_writer_001_0010(b: &mut Bencher) {
do_bench_seekable_mem_writer(b, 1, 10)
}
#[bench]
fn bench_seekable_mem_writer_001_0100(b: &mut ... | {
let src: Vec<u8> = repeat(5).take(len).collect();
b.bytes = (times * len) as u64;
b.iter(|| {
let mut wr = SeekableMemWriter::new();
for _ in 0..times {
wr.write(&src).unwrap();
}
let v = wr.unwrap();
assert_eq!(v.le... | identifier_body |
io.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... |
// Figure out what bytes will be used to overwrite what's currently
// there (left), and what will be appended on the end (right)
let cap = self.buf.len() - self.pos;
let (left, right) = if cap <= buf.len() {
(&buf[..cap], &buf[cap..])
} else... | {
self.buf.extend(repeat(0).take(difference as uint));
} | conditional_block |
expr-block-generic-box1.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | <T>(expected: @T, eq: compare<T>) {
let actual: @T = { expected };
assert!((eq(expected, actual)));
}
fn test_box() {
fn compare_box(b1: @bool, b2: @bool) -> bool {
info!("{}", *b1);
info!("{}", *b2);
return *b1 == *b2;
}
test_generic::<bool>(@true, compare_box);
}
pub fn m... | test_generic | identifier_name |
expr-block-generic-box1.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at | // <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.
#[feature(managed_boxes)];
type compare<T> ='static |@T, @T| -> bool;
fn test_generic<T>(expected: @T, eq: compare<T>) {
let actual: @T = { expected... | // 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 | random_line_split |
expr-block-generic-box1.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
fn test_box() {
fn compare_box(b1: @bool, b2: @bool) -> bool {
info!("{}", *b1);
info!("{}", *b2);
return *b1 == *b2;
}
test_generic::<bool>(@true, compare_box);
}
pub fn main() { test_box(); }
| {
let actual: @T = { expected };
assert!((eq(expected, actual)));
} | identifier_body |
send_str_treemap.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 ... | () {
let mut map: TreeMap<SendStr, uint> = TreeMap::new();
assert!(map.insert(Slice("foo"), 42));
assert!(!map.insert(Owned("foo".to_string()), 42));
assert!(!map.insert(Slice("foo"), 42));
assert!(!map.insert(Owned("foo".to_string()), 42));
assert!(!map.insert(Slice("foo"), 43));
assert!(!... | main | identifier_name |
send_str_treemap.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 ... |
assert!(!map.insert(Slice("abc"), a));
assert!(!map.insert(Owned("bcd".to_string()), b));
assert!(!map.insert(Slice("cde"), c));
assert!(!map.insert(Owned("def".to_string()), d));
assert!(!map.insert(Owned("abc".to_string()), a));
assert!(!map.insert(Slice("bcd"), b));
assert!(!map.insert(... |
assert!(map.insert(Slice("abc"), a));
assert!(map.insert(Owned("bcd".to_string()), b));
assert!(map.insert(Slice("cde"), c));
assert!(map.insert(Owned("def".to_string()), d)); | random_line_split |
send_str_treemap.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 ... | assert!(map.insert(Owned("bcd".to_string()), b));
assert!(map.insert(Slice("cde"), c));
assert!(map.insert(Owned("def".to_string()), d));
assert!(!map.insert(Slice("abc"), a));
assert!(!map.insert(Owned("bcd".to_string()), b));
assert!(!map.insert(Slice("cde"), c));
assert!(!map.insert(Owne... | {
let mut map: TreeMap<SendStr, uint> = TreeMap::new();
assert!(map.insert(Slice("foo"), 42));
assert!(!map.insert(Owned("foo".to_string()), 42));
assert!(!map.insert(Slice("foo"), 42));
assert!(!map.insert(Owned("foo".to_string()), 42));
assert!(!map.insert(Slice("foo"), 43));
assert!(!map... | identifier_body |
md5.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 ... |
fn reset(&mut self) {
self.s0 = 0x67452301;
self.s1 = 0xefcdab89;
self.s2 = 0x98badcfe;
self.s3 = 0x10325476;
}
fn process_block(&mut self, input: &[u8]) {
fn f(u: u32, v: u32, w: u32) -> u32 {
return (u & v) | (!u & w);
}
fn g(u: u32, ... | {
return Md5State {
s0: 0x67452301,
s1: 0xefcdab89,
s2: 0x98badcfe,
s3: 0x10325476
};
} | identifier_body |
md5.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 ... | () -> Md5 {
return Md5 {
length_bytes: 0,
buffer: FixedBuffer64::new(),
state: Md5State::new(),
finished: false
}
}
}
impl Digest for Md5 {
fn input(&mut self, input: &[u8]) {
assert!(!self.finished);
// Unlike Sha1 and Sha2, the l... | new | identifier_name |
md5.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 ... |
write_u32_le(out.mut_slice(0, 4), self.state.s0);
write_u32_le(out.mut_slice(4, 8), self.state.s1);
write_u32_le(out.mut_slice(8, 12), self.state.s2);
write_u32_le(out.mut_slice(12, 16), self.state.s3);
}
fn output_bits(&self) -> uint { 128 }
fn block_size(&self) -> uint ... | {
let self_state = &mut self.state;
self.buffer.standard_padding(8, |d: &[u8]| { self_state.process_block(d); });
write_u32_le(self.buffer.next(4), (self.length_bytes << 3) as u32);
write_u32_le(self.buffer.next(4), (self.length_bytes >> 29) as u32);
self_stat... | conditional_block |
md5.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | use digest::Digest;
// A structure that represents that state of a digest computation for the MD5 digest function
struct Md5State {
s0: u32,
s1: u32,
s2: u32,
s3: u32
}
impl Md5State {
fn new() -> Md5State {
return Md5State {
s0: 0x67452301,
s1: 0xefcdab89,
... |
use std::iter::range_step;
use cryptoutil::{write_u32_le, read_u32v_le, FixedBuffer, FixedBuffer64, StandardPadding}; | random_line_split |
cstore.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... |
}
}
| {
let len = (((slice[0] as u32) << 24) |
((slice[1] as u32) << 16) |
((slice[2] as u32) << 8) |
((slice[3] as u32) << 0)) as usize;
if len + 4 <= slice.len() {
&slice[4.. len + 4]
} else {
... | conditional_block |
cstore.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... | *self.codemap_import_info.borrow_mut() = filemaps;
self.codemap_import_info.borrow()
} else {
filemaps
}
}
pub fn with_local_path<T, F>(&self, f: F) -> T
where F: Fn(&[ast_map::PathElem]) -> T {
let cpath = self.local_path.borrow();
if cpat... |
// This shouldn't borrow twice, but there is no way to downgrade RefMut to Ref. | random_line_split |
cstore.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... | {
MetadataVec(Bytes),
MetadataArchive(loader::ArchiveMetadata),
}
/// Holds information about a codemap::FileMap imported from another crate.
/// See creader::import_codemap() for more information.
pub struct ImportedFileMap {
/// This FileMap's byte-offset within the codemap of its original crate
pub... | MetadataBlob | identifier_name |
cstore.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... |
// This method is used when generating the command line to pass through to
// system linker. The linker expects undefined symbols on the left of the
// command line to be defined in libraries on the right, not the other way
// around. For more info, see some comments in the add_used_library function
... | {
self.metas.borrow_mut().clear();
self.extern_mod_crate_map.borrow_mut().clear();
self.used_crate_sources.borrow_mut().clear();
self.used_libraries.borrow_mut().clear();
self.used_link_args.borrow_mut().clear();
} | identifier_body |
wallet_library.rs | // Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0
//! The following document is a minimalist version of Diem Wallet. Note that this Wallet does
//! not promote security as the mnemonic is stored in unencrypted form. In future iterations,
//! we will be releasing more robust Wallet impl... | (&self, address: &AccountAddress) -> Result<AuthenticationKey> {
if let Some(child) = self.addr_map.get(&address) {
Ok(self
.key_factory
.private_child(*child)?
.get_authentication_key())
} else {
Err(WalletError::DiemWalletGeneric("mi... | get_authentication_key | identifier_name |
wallet_library.rs | // Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0
//! The following document is a minimalist version of Diem Wallet. Note that this Wallet does
//! not promote security as the mnemonic is stored in unencrypted form. In future iterations,
//! we will be releasing more robust Wallet impl... | } | random_line_split | |
wallet_library.rs | // Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0
//! The following document is a minimalist version of Diem Wallet. Note that this Wallet does
//! not promote security as the mnemonic is stored in unencrypted form. In future iterations,
//! we will be releasing more robust Wallet impl... |
/// Return authentication key (AuthenticationKey) for an address in the wallet
pub fn get_authentication_key(&self, address: &AccountAddress) -> Result<AuthenticationKey> {
if let Some(child) = self.addr_map.get(&address) {
Ok(self
.key_factory
.private_child(... | {
if let Some(child) = self.addr_map.get(&address) {
Ok(self.key_factory.private_child(*child)?.get_private_key())
} else {
Err(WalletError::DiemWalletGeneric("missing address".to_string()).into())
}
} | identifier_body |
mod.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... | match tname.get() {
"Clone" => expand!(clone::expand_deriving_clone),
"Hash" => expand!(hash::expand_deriving_hash),
"Encodable" => expand!(encodable::expand_deriving_encodable),
"De... | {
match mitem.node {
MetaNameValue(_, ref l) => {
cx.span_err(l.span, "unexpected value in `deriving`");
}
MetaWord(_) => {
cx.span_warn(mitem.span, "empty trait list in `deriving`");
}
MetaList(_, ref titems) if titems.len() == 0 => {
cx.s... | identifier_body |
mod.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... | (cx: &mut ExtCtxt,
_span: Span,
mitem: @MetaItem,
item: @Item,
push: |@Item|) {
match mitem.node {
MetaNameValue(_, ref l) => {
cx.span_err(l.span, "unexpected value in `deriving`");
... | expand_meta_deriving | identifier_name |
mod.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 default;
pub mod primitive;
#[path="cmp/eq.rs"]
pub mod eq;
#[path="cmp/totaleq.rs"]
pub mod totaleq;
#[path="cmp/ord.rs"]
pub mod ord;
#[path="cmp/totalord.rs"]
pub mod totalord;
pub mod generic;
pub fn expand_meta_deriving(cx: &mut ExtCtxt,
_span: Span,
... | pub mod decodable;
pub mod hash;
pub mod rand;
pub mod show;
pub mod zero; | random_line_split |
init-res-into-things.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () {
test_box();
test_rec();
test_tag();
test_tup();
test_unique();
test_box_rec();
}
| main | identifier_name |
init-res-into-things.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or |
// Resources can't be copied, but storing into data structures counts
// as a move unless the stored thing is used afterwards.
struct r {
i: @mut int,
}
struct Box { x: r }
#[unsafe_destructor]
impl Drop for r {
fn finalize(&self) {
unsafe {
*(self.i) = *(self.i) + 1;
}
}
}
fn... | // 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. | random_line_split |
init-res-into-things.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
fn test_box() {
let i = @mut 0;
{
let a = @r(i);
}
assert!(*i == 1);
}
fn test_rec() {
let i = @mut 0;
{
let a = Box {x: r(i)};
}
assert!(*i == 1);
}
fn test_tag() {
enum t {
t0(r),
}
let i = @mut 0;
{
let a = t0(r(i));
}
asser... | {
r {
i: i
}
} | identifier_body |
test_type_error.rs | /*
* Copyright 2021 Google LLC.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to ... |
}
| {
compile("type_error", "test_inputs", "test_outputs", "");
} | identifier_body |
test_type_error.rs | /*
* Copyright 2021 Google LLC.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to ... | () {
compile("type_error", "test_inputs", "test_outputs", "");
}
}
| test_type_error | identifier_name |
test_type_error.rs | *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distribut... | /*
* Copyright 2021 Google LLC. | random_line_split | |
lib.rs | // Copyright 2016 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable... |
fn handle_request(&mut self, mut ctx: RpcCtx, method: &str, params: &Value) ->
Result<Value, Value> {
match Request::from_json(method, params) {
Ok(req) => {
let result = self.handle_req(req, &mut ctx);
result.ok_or_else(|| json!("return value missing"))... | {
match Request::from_json(method, params) {
Ok(req) => {
if let Some(_) = self.handle_req(req, &mut ctx) {
print_err!("Unexpected return value for notification {}", method)
}
}
Err(e) => print_err!("Error {} decoding RPC re... | identifier_body |
lib.rs | // Copyright 2016 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable... | print_err!("Error {} decoding RPC request {}", e, method);
Err(json!("error decoding request"))
}
}
}
fn idle(&mut self, _ctx: RpcCtx, _token: usize) {
self.tabs.handle_idle();
}
}
impl MainState {
fn handle_req(&mut self, request: Request, r... | Err(e) => { | random_line_split |
lib.rs | // Copyright 2016 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable... | (&mut self, request: Request, rpc_ctx: &mut RpcCtx) ->
Option<Value> {
match request {
Request::CoreCommand { core_command } => self.tabs.do_rpc(core_command, rpc_ctx)
}
}
}
| handle_req | identifier_name |
nok.rs | use std::marker::PhantomData;
/// `Nok` contains the content of an error response from the CouchDB server.
///
/// # Summary
///
/// * `Nok` has public members instead of accessor methods because there are no
/// invariants restricting the data.
///
/// * `Nok` implements `Deserialize`.
///
/// # Remarks
///
/// Whe... | ub error: String,
pub reason: String,
#[serde(default = "PhantomData::default")]
_private_guard: PhantomData<()>,
}
| p | identifier_name |
nok.rs | use std::marker::PhantomData;
/// `Nok` contains the content of an error response from the CouchDB server.
///
/// # Summary
///
/// * `Nok` has public members instead of accessor methods because there are no
/// invariants restricting the data.
///
/// * `Nok` implements `Deserialize`.
///
/// # Remarks
///
/// Whe... | ///
/// `Nok` contains a dummy private member in order to prevent applications from
/// directly constructing a `Nok` instance. This allows new fields to be added
/// to `Nok` in future releases without it being a breaking change.
///
#[derive(Clone, Debug, Default, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd)]
p... | /// ```
///
/// # Compatibility | random_line_split |
helloworld.rs | extern crate redis;
use std::thread;
use redis::{RedisResult, Value as RedisValue, Commands};
fn main() | let connection = client.get_connection().expect("Couldn't open connection");
let thread_handle = thread::spawn(move || {
for _ in 0..10 {
let msgs = [
format!("message 1 from producer {}", consumer_num),
format!("message 2 from produce... | {
// connect to local host, default port
let queue_name = "my_queue";
let get_timeout = 5;
let get_count = 2;
let client = redis::Client::open("redis://127.0.0.1:9797/").unwrap();
let mut thread_handles = Vec::new();
let connection = client.get_connection().expect("Couldn't open connection")... | identifier_body |
helloworld.rs | extern crate redis;
use std::thread;
use redis::{RedisResult, Value as RedisValue, Commands};
fn | () {
// connect to local host, default port
let queue_name = "my_queue";
let get_timeout = 5;
let get_count = 2;
let client = redis::Client::open("redis://127.0.0.1:9797/").unwrap();
let mut thread_handles = Vec::new();
let connection = client.get_connection().expect("Couldn't open connectio... | main | identifier_name |
helloworld.rs | extern crate redis;
use std::thread;
use redis::{RedisResult, Value as RedisValue, Commands};
fn main() {
// connect to local host, default port
let queue_name = "my_queue";
let get_timeout = 5;
let get_count = 2;
let client = redis::Client::open("redis://127.0.0.1:9797/").unwrap();
let mut th... | let maybe_result: RedisResult<Vec<Vec<RedisValue>>> =
redis::cmd("HMGET")
.arg(queue_name).arg(channel_name).arg(get_count).arg(get_timeout)
.query(&connection);
let result = match maybe_result {
Err(_) => may... | let thread_handle = thread::spawn(move || {
loop { | random_line_split |
test_md5mesh.rs | use implement::file::md5common;
use implement::file::md5mesh;
#[test]
fn test_parse_md5mesh(){
let file_content = md5common::file_open( "core/asset/md5/qshambler.md5mesh" ).expect("file open invalid");
println!("file content length: {}", file_content.len() );
let _mesh_root = md5mesh::parse( &file_content ... | // for j in i._weights.iter() {
// println!("weight index: {}, joint index: {}, weight bias: {}, pos: {:?}", j._index, j._joint_index, j._weight_bias, j._pos );
// }
// println!( "}}" );
// }
} | // }
// println!( "numweights: {}", i._numweights ); | random_line_split |
test_md5mesh.rs | use implement::file::md5common;
use implement::file::md5mesh;
#[test]
fn test_parse_md5mesh() | // println!( "numweights: {}", i._numweights );
// for j in i._weights.iter() {
// println!("weight index: {}, joint index: {}, weight bias: {}, pos: {:?}", j._index, j._joint_index, j._weight_bias, j._pos );
// }
// println!( "}}" );
// }
}
| {
let file_content = md5common::file_open( "core/asset/md5/qshambler.md5mesh" ).expect("file open invalid");
println!("file content length: {}", file_content.len() );
let _mesh_root = md5mesh::parse( &file_content ).expect("parse unsuccessful");
// for i in mesh_root._joints.iter() {
// println... | identifier_body |
test_md5mesh.rs | use implement::file::md5common;
use implement::file::md5mesh;
#[test]
fn | (){
let file_content = md5common::file_open( "core/asset/md5/qshambler.md5mesh" ).expect("file open invalid");
println!("file content length: {}", file_content.len() );
let _mesh_root = md5mesh::parse( &file_content ).expect("parse unsuccessful");
// for i in mesh_root._joints.iter() {
// print... | test_parse_md5mesh | identifier_name |
m_1_2_01.rs | // M_1_2_01
//
// Generative Gestaltung β Creative Coding im Web
// ISBN: 978-3-87439-902-9, First Edition, Hermann Schmidt, Mainz, 2018
// Benedikt GroΓ, Hartmut Bohnacker, Julia Laub, Claudius Lazzeroni
// with contributions by Joey Lee and Niels Poldervaart
// Copyright 2018
//
// http://www.generative-gestaltung.de... | }
} | fn key_pressed(app: &App, _model: &mut Model, key: Key) {
if key == Key::S {
app.main_window()
.capture_frame(app.exe_name().unwrap() + ".png"); | random_line_split |
m_1_2_01.rs | // M_1_2_01
//
// Generative Gestaltung β Creative Coding im Web
// ISBN: 978-3-87439-902-9, First Edition, Hermann Schmidt, Mainz, 2018
// Benedikt GroΓ, Hartmut Bohnacker, Julia Laub, Claudius Lazzeroni
// with contributions by Joey Lee and Niels Poldervaart
// Copyright 2018
//
// http://www.generative-gestaltung.de... | app.main_window()
.capture_frame(app.exe_name().unwrap() + ".png");
}
}
| conditional_block | |
m_1_2_01.rs | // M_1_2_01
//
// Generative Gestaltung β Creative Coding im Web
// ISBN: 978-3-87439-902-9, First Edition, Hermann Schmidt, Mainz, 2018
// Benedikt GroΓ, Hartmut Bohnacker, Julia Laub, Claudius Lazzeroni
// with contributions by Joey Lee and Niels Poldervaart
// Copyright 2018
//
// http://www.generative-gestaltung.de... | p: &App, _model: &mut Model, key: Key) {
if key == Key::S {
app.main_window()
.capture_frame(app.exe_name().unwrap() + ".png");
}
}
| _pressed(ap | identifier_name |
m_1_2_01.rs | // M_1_2_01
//
// Generative Gestaltung β Creative Coding im Web
// ISBN: 978-3-87439-902-9, First Edition, Hermann Schmidt, Mainz, 2018
// Benedikt GroΓ, Hartmut Bohnacker, Julia Laub, Claudius Lazzeroni
// with contributions by Joey Lee and Niels Poldervaart
// Copyright 2018
//
// http://www.generative-gestaltung.de... | draw.ellipse().x_y(x, y).w_h(11.0, 11.0).rgb8(0, 130, 163);
}
// Write to the window frame.
draw.to_frame(app, &frame).unwrap();
}
f
n mouse_pressed(_app: &App, model: &mut Model, _button: MouseButton) {
model.act_random_seed = (random_f32() * 100000.0) as u64;
}
fn key_pressed(app: &App, _mo... | let draw = app.draw();
let win = app.window_rect();
draw.background().color(WHITE);
let fader_x = map_range(app.mouse.x, win.left(), win.right(), 0.0, 1.0);
let mut rng = StdRng::seed_from_u64(model.act_random_seed);
let angle = deg_to_rad(360.0 / model.count as f32);
for i in 0..model.co... | identifier_body |
stream.rs | .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.
/// Stream channels
///
/// This is the flavor of channels which are optimized for one sender and one
/// re... | (&mut self, up: Receiver<T>) -> UpgradeResult {
// If the port has gone away, then there's no need to proceed any
// further.
if self.port_dropped.load(Ordering::SeqCst) { return UpDisconnected }
self.do_send(GoUp(up))
}
fn do_send(&mut self, t: Message<T>) -> UpgradeResult {
... | upgrade | identifier_name |
stream.rs | 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.
/// Stream channels
///
/// This is the flavor of channels which are optimized for one sender and one
... | use thread;
use sync::atomic::{AtomicIsize, AtomicUsize, Ordering, AtomicBool};
use sync::mpsc::Receiver;
use sync::mpsc::blocking::{self, SignalToken};
use sync::mpsc::spsc_queue as spsc;
const DISCONNECTED: isize = isize::MIN;
#[cfg(test)]
const MAX_STEALS: isize = 5;
#[cfg(not(test))]
const MAX_STEALS: isize = 1 <... | use core::prelude::*;
use core::cmp;
use core::isize; | random_line_split |
stream.rs | .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.
/// Stream channels
///
/// This is the flavor of channels which are optimized for one sender and one
/// re... | self.steals -= 1;
data
}
data => data,
}
}
pub fn try_recv(&mut self) -> Result<T, Failure<T>> {
match self.queue.pop() {
// If we stole some data, record to that effect (this will be
// factored into cnt later on... | {
// Optimistic preflight check (scheduling is expensive).
match self.try_recv() {
Err(Empty) => {}
data => return data,
}
// Welp, our channel has no data. Deschedule the current task and
// initiate the blocking protocol.
let (wait_token, signal... | identifier_body |
arm64.rs | use execstate::ExecState;
use object::{Obj, Ref};
pub use self::param::*;
pub use self::reg::*;
pub mod asm;
pub mod param;
pub mod reg;
pub mod trap;
pub fn flush_icache(start: *const u8, len: usize) {
let start = start as usize;
let end = start + len;
let (icacheline_size, dcacheline_size) = cacheline... | (es: &ExecState) -> Ref<Obj> {
let obj: Ref<Obj> = es.regs[REG_RESULT.asm() as usize].into();
obj
}
pub fn ra_from_execstate(es: &ExecState) -> usize {
es.regs[REG_LR.asm() as usize]
}
| get_exception_object | identifier_name |
arm64.rs | use execstate::ExecState;
use object::{Obj, Ref};
pub use self::param::*;
pub use self::reg::*;
pub mod asm;
pub mod param;
pub mod reg;
pub mod trap;
pub fn flush_icache(start: *const u8, len: usize) {
let start = start as usize;
let end = start + len;
let (icacheline_size, dcacheline_size) = cacheline... | unsafe {
asm!("dc civac, $0":: "r"(ptr) : "memory" : "volatile");
}
ptr += dcacheline_size;
}
unsafe {
asm!("dsb ish" ::: "memory" : "volatile");
}
ptr = istart;
while ptr < end {
unsafe {
asm!("ic ivau, $0":: "r"(ptr) : "memory" : ... | while ptr < end { | random_line_split |
arm64.rs | use execstate::ExecState;
use object::{Obj, Ref};
pub use self::param::*;
pub use self::reg::*;
pub mod asm;
pub mod param;
pub mod reg;
pub mod trap;
pub fn flush_icache(start: *const u8, len: usize) {
let start = start as usize;
let end = start + len;
let (icacheline_size, dcacheline_size) = cacheline... |
pub fn ra_from_execstate(es: &ExecState) -> usize {
es.regs[REG_LR.asm() as usize]
}
| {
let obj: Ref<Obj> = es.regs[REG_RESULT.asm() as usize].into();
obj
} | identifier_body |
htmlunknownelement.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::HTMLUnknownElementBinding;
use dom::bindings::js::Root;
use dom::bindings::s... | prefix: Option<DOMString>,
document: &Document) -> HTMLUnknownElement {
HTMLUnknownElement {
htmlelement:
HTMLElement::new_inherited(localName, prefix, document)
}
}
#[allow(unrooted_must_root)]
pub fn new(localName: Atom... | random_line_split | |
htmlunknownelement.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::HTMLUnknownElementBinding;
use dom::bindings::js::Root;
use dom::bindings::s... | {
htmlelement: HTMLElement
}
impl HTMLUnknownElement {
fn new_inherited(localName: Atom,
prefix: Option<DOMString>,
document: &Document) -> HTMLUnknownElement {
HTMLUnknownElement {
htmlelement:
HTMLElement::new_inherited(localName,... | HTMLUnknownElement | identifier_name |
htmlunknownelement.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::HTMLUnknownElementBinding;
use dom::bindings::js::Root;
use dom::bindings::s... |
}
| {
Node::reflect_node(box HTMLUnknownElement::new_inherited(localName, prefix, document),
document,
HTMLUnknownElementBinding::Wrap)
} | identifier_body |
error.rs | use std::io;
use std::result;
use mqtt3;
use tokio_timer::TimerError;
pub type Result<T> = result::Result<T, Error>;
quick_error! {
#[derive(Debug)]
pub enum Error {
Io(err: io::Error) {
from()
description("io error")
display("I/O error: {}", err)
cause... | }
InvalidMqttPacket {
description("Invalid Mqtt Packet")
}
InvalidClientId {
description("Invalid Client ID")
}
DisconnectRequest {
description("Received Disconnect Request")
}
NotInQueue {
description("Could... | ClientIdExists {
description("Client with that ID already exists") | random_line_split |
main.rs | macro_rules! timeit {
($func:expr) => ({
let t1 = std::time::Instant::now();
println!("{:?}", $func);
let t2 = std::time::Instant::now().duration_since(t1);
println!("{}", t2.as_secs() as f64 + t2.subsec_nanos() as f64 / 1000000000.00);
})
}
fn main() | {
fn fib(n: usize) -> usize {
match n <= 3 {
true => n,
false => return fib(n - 1) + fib(n - 2),
}
}
fn even_fibs(n: usize) -> usize {
(1..)
.map(|x| fib(x))
.take_while(|&x| x <= n as usize)
.filter(|&x| x % 2 == 0)
... | identifier_body | |
main.rs | macro_rules! timeit {
($func:expr) => ({
let t1 = std::time::Instant::now();
println!("{:?}", $func);
let t2 = std::time::Instant::now().duration_since(t1);
println!("{}", t2.as_secs() as f64 + t2.subsec_nanos() as f64 / 1000000000.00);
})
}
fn main() {
fn fib(n: usize) -> ... | false => return fib(n - 1) + fib(n - 2),
}
}
fn even_fibs(n: usize) -> usize {
(1..)
.map(|x| fib(x))
.take_while(|&x| x <= n as usize)
.filter(|&x| x % 2 == 0)
.fold(0, |acc, item| acc + item)
}
timeit!(even_fibs(4000000))
} | true => n, | random_line_split |
main.rs | macro_rules! timeit {
($func:expr) => ({
let t1 = std::time::Instant::now();
println!("{:?}", $func);
let t2 = std::time::Instant::now().duration_since(t1);
println!("{}", t2.as_secs() as f64 + t2.subsec_nanos() as f64 / 1000000000.00);
})
}
fn main() {
fn fib(n: usize) -> ... | (n: usize) -> usize {
(1..)
.map(|x| fib(x))
.take_while(|&x| x <= n as usize)
.filter(|&x| x % 2 == 0)
.fold(0, |acc, item| acc + item)
}
timeit!(even_fibs(4000000))
}
| even_fibs | identifier_name |
lexical-scope-in-match.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... |
}
match (235, 236) {
// with literal
(235, shadowed) => {
zzz();
sentinel();
}
_ => {}
}
match Struct { x: 237, y: 238 } {
Struct { x: shadowed, y: local_to_arm } => {
zzz();
sentinel();
}
}
mat... | {
zzz();
sentinel();
} | conditional_block |
lexical-scope-in-match.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... | {
x: int,
y: int
}
fn main() {
let shadowed = 231;
let not_shadowed = 232;
zzz();
sentinel();
match (233, 234) {
(shadowed, local_to_arm) => {
zzz();
sentinel();
}
}
match (235, 236) {
// with literal
(235, shadowed) => {... | Struct | identifier_name |
lexical-scope-in-match.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... |
// compile-flags:-g
// debugger:rbreak zzz
// debugger:run
// debugger:finish
// debugger:print shadowed
// check:$1 = 231
// debugger:print not_shadowed
// check:$2 = 232
// debugger:continue
// debugger:finish
// debugger:print shadowed
// check:$3 = 233
// debugger:print not_shadowed
// check:$4 = 232
// debugger... | // ignore-android: FIXME(#10381) | random_line_split |
serviceworkerglobalscope.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 devtools;
use devtools_traits::DevtoolScriptControlMsg;
use dom::abstractworker::WorkerScriptMsg;
use dom::bin... | else {
panic!("unexpected select result!")
}
}
pub fn process_event(&self, msg: CommonScriptMsg) {
self.handle_script_event(ServiceWorkerScriptMsg::CommonWorker(WorkerScriptMsg::Common(msg)));
}
pub fn script_chan(&self) -> Box<ScriptChan + Send> {
box ServiceWorke... | {
Ok(MixedMessage::FromTimeoutThread(try!(timer_event_port.recv())))
} | conditional_block |
serviceworkerglobalscope.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 devtools;
use devtools_traits::DevtoolScriptControlMsg;
use dom::abstractworker::WorkerScriptMsg;
use dom::bin... | {
workerglobalscope: WorkerGlobalScope,
#[ignore_heap_size_of = "Defined in std"]
receiver: Receiver<ServiceWorkerScriptMsg>,
#[ignore_heap_size_of = "Defined in std"]
own_sender: Sender<ServiceWorkerScriptMsg>,
#[ignore_heap_size_of = "Defined in std"]
timer_event_port: Receiver<()>,
#... | ServiceWorkerGlobalScope | identifier_name |
serviceworkerglobalscope.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 devtools;
use devtools_traits::DevtoolScriptControlMsg;
use dom::abstractworker::WorkerScriptMsg;
use dom::bin... | let sw_lifetime_timeout = PREFS.get("dom.serviceworker.timeout_seconds").as_u64().unwrap();
thread::sleep(Duration::new(sw_lifetime_timeout, 0));
let _ = timer_chan.send(());
});
global.dispatch_activate();
let reporter_name = format!(... | random_line_split | |
mods.rs | use std::collections::{HashSet};
use spiral;
use spiral::to_spine::{ProgSt, Env, Res};
use spiral::to_spine::decls::{translate_decls};
use spine::onion::{Onion};
pub struct | {
module: spiral::Mod,
required: HashSet<spiral::ModName>,
}
pub fn load_mods(prog: &spiral::Prog,
mod_loader: &mut (FnMut(&spiral::ModName) -> Result<spiral::Mod, String>))
-> Res<Vec<LoadedMod>>
{
let mut loaded_mods = Vec::new();
let mut loaded_names = HashSet::new();
let mut required_names = spiral:... | LoadedMod | identifier_name |
mods.rs | use std::collections::{HashSet};
use spiral;
use spiral::to_spine::{ProgSt, Env, Res};
use spiral::to_spine::decls::{translate_decls};
use spine::onion::{Onion};
pub struct LoadedMod {
module: spiral::Mod,
required: HashSet<spiral::ModName>,
}
pub fn load_mods(prog: &spiral::Prog,
mod_loader: &mut (FnMut(&spira... |
}
Ok(loaded_mods)
}
pub fn translate_mods(st: &mut ProgSt, env: Env, loaded_mods: Vec<LoadedMod>)
-> Res<(Vec<Onion>, Env)>
{
let mut remaining_mods = loaded_mods;
let mut translated_names = HashSet::new();
let mut translated_onions = Vec::new();
let mut mods_env = env;
while!remaining_mods.is_empty... | {
required_names = HashSet::new();
for new_mod in new_mods.into_iter() {
required_names.extend(new_mod.required.iter().cloned());
loaded_mods.push(new_mod);
}
} | conditional_block |
mods.rs | use std::collections::{HashSet};
use spiral;
use spiral::to_spine::{ProgSt, Env, Res};
use spiral::to_spine::decls::{translate_decls};
use spine::onion::{Onion};
pub struct LoadedMod {
module: spiral::Mod,
required: HashSet<spiral::ModName>,
}
pub fn load_mods(prog: &spiral::Prog,
mod_loader: &mut (FnMut(&spira... | new_mods.push(LoadedMod {
required: spiral::imported::collect_mod(&module),
module: module,
});
}
}
if new_mods.is_empty() {
break
} else {
required_names = HashSet::new();
for new_mod in new_mods.into_iter() {
required_names.extend(new_mo... | return Err(format!("Loaded module '{}', but got '{}'",
required_name.0, module.name.0));
}
loaded_names.insert(required_name); | random_line_split |
mods.rs | use std::collections::{HashSet};
use spiral;
use spiral::to_spine::{ProgSt, Env, Res};
use spiral::to_spine::decls::{translate_decls};
use spine::onion::{Onion};
pub struct LoadedMod {
module: spiral::Mod,
required: HashSet<spiral::ModName>,
}
pub fn load_mods(prog: &spiral::Prog,
mod_loader: &mut (FnMut(&spira... | }
}
if new_mods.is_empty() {
break
} else {
required_names = HashSet::new();
for new_mod in new_mods.into_iter() {
required_names.extend(new_mod.required.iter().cloned());
loaded_mods.push(new_mod);
}
}
}
Ok(loaded_mods)
}
pub fn translate_mods(st: &... | {
let mut loaded_mods = Vec::new();
let mut loaded_names = HashSet::new();
let mut required_names = spiral::imported::collect_prog(prog);
loop {
let mut new_mods = Vec::new();
for required_name in required_names.into_iter() {
if !loaded_names.contains(&required_name) {
let module = try!(... | identifier_body |
ring.rs | use super::util::{CacheKeyPath,
ConfigOptCacheKeyPath};
use configopt::ConfigOpt;
use structopt::StructOpt;
#[derive(ConfigOpt, StructOpt)]
#[structopt(no_version)]
/// Commands relating to Habitat rings
pub enum | {
Key(Key),
}
#[derive(ConfigOpt, StructOpt)]
#[structopt(no_version)]
/// Commands relating to Habitat ring keys
pub enum Key {
/// Outputs the latest ring key contents to stdout
Export {
/// Ring key name
#[structopt(name = "RING")]
ring: String,
#[structopt(fla... | Ring | identifier_name |
ring.rs | use super::util::{CacheKeyPath,
ConfigOptCacheKeyPath};
use configopt::ConfigOpt;
use structopt::StructOpt;
#[derive(ConfigOpt, StructOpt)]
#[structopt(no_version)]
/// Commands relating to Habitat rings
pub enum Ring {
Key(Key),
}
#[derive(ConfigOpt, StructOpt)]
#[structopt(no_version)]
/// Com... | cache_key_path: CacheKeyPath,
},
/// Generates a Habitat ring key
Generate {
/// Ring key name
#[structopt(name = "RING")]
ring: String,
#[structopt(flatten)]
cache_key_path: CacheKeyPath,
},
/// Reads a stdin stream containing ring key conte... | #[structopt(flatten)] | random_line_split |
lib.rs | extern crate rl_sys;
extern crate lalrpop_util;
#[macro_use] extern crate stepper;
extern crate unicode_xid;
#[macro_use]
mod macros;
mod ast;
mod error;
mod eval;
mod grammar;
mod parser;
mod stream;
mod token;
mod state;
use std::fs::{File, OpenOptions};
use std::io::{self, Read, Write};
use std::path::Path;
use s... | let mut state = State::new();
let mut stderr = io::stderr();
// Create history file if it doesn't already exist.
OpenOptions::new().write(true).create(true).truncate(false).open(".history").expect("Unable to create history file");
// Read in history from the file.
histfile::read(Some(Path::new... | }
pub fn repl() { | random_line_split |
lib.rs | extern crate rl_sys;
extern crate lalrpop_util;
#[macro_use] extern crate stepper;
extern crate unicode_xid;
#[macro_use]
mod macros;
mod ast;
mod error;
mod eval;
mod grammar;
mod parser;
mod stream;
mod token;
mod state;
use std::fs::{File, OpenOptions};
use std::io::{self, Read, Write};
use std::path::Path;
use s... | (file_name: &str) -> Result<()> {
let mut file = File::open(file_name).expect("Unable to open file");
let mut program_str = String::new();
file.read_to_string(&mut program_str).expect("Unable to read file");
run_program(&program_str)
}
pub fn run_program(program_str: &str) -> Result<()> {
let prog... | run_file | identifier_name |
lib.rs | extern crate rl_sys;
extern crate lalrpop_util;
#[macro_use] extern crate stepper;
extern crate unicode_xid;
#[macro_use]
mod macros;
mod ast;
mod error;
mod eval;
mod grammar;
mod parser;
mod stream;
mod token;
mod state;
use std::fs::{File, OpenOptions};
use std::io::{self, Read, Write};
use std::path::Path;
use s... |
pub fn run_program_with_stream(program_str: &str) -> Arc<Stream> {
let program = parse_program(&program_str).unwrap();
let stream = Arc::new(Stream::new());
let cloned_stream = stream.clone();
let mut state = State::new();
thread::spawn(move || {
for stmt in program {
if let E... | {
let program = parse_program(&program_str).unwrap();
let mut state = State::new();
for stmt in program {
try!(stmt.eval(&mut state, None));
}
Ok(())
} | identifier_body |
levenshtein.rs | // Copyright (c) 2016. See AUTHORS file.
//
// 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 agr... | /// that are neccessary to convert one string into annother.
/// This implementation does fully support unicode strings.
///
/// ## Complexity
/// m := len(s) + 1
/// n := len(t) + 1
///
/// Time complexity: O(mn)
/// Space complexity: O(mn)
///
/// ## Examples
/// ```
/// use distance::*;
///
/// // Levens... | random_line_split |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.