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
main.rs
#[macro_use] extern crate lazy_static; extern crate md5; use md5::compute; fn next_pair(input: &[u8], pepper: &mut u64) -> Option<(u8, u8)> { let mut preimage = Vec::new(); // Ignore edge case where maximum pepper yields the digit. while *pepper!= u64::max_value() { preimage.clear(); pr...
.join("")) } fn main() { lazy_static! { static ref INPUT: Vec<u8> = "ugkcyxxp".bytes().collect(); } match solve_one(&INPUT) { Some(password) => println!("[1] Found the password: {}.", password), _ => println!("[1] Could not find the password."), } match solve_two(&...
{ let (mut free, mut pepper) = (8, 0u64); let mut password = [!0u8; 8]; while free != 0 { match next_pair(input, &mut pepper) { Some((position, digit)) => { let position = position as usize; if position < 8 && password[position] == !0u8 { ...
identifier_body
lib.rs
#![feature(alloc_layout_extra)] #![feature(array_chunks)] #![feature(array_methods)] #![feature(array_windows)] #![feature(bool_to_option)] #![feature(box_syntax)] #![feature(cell_update)] #![feature(cfg_panic)] #![feature(cfg_target_has_atomic)] #![feature(const_assume)] #![feature(const_cell_into_inner)] #![feature(c...
#![feature(min_specialization)] #![feature(numfmt)] #![feature(step_trait)] #![feature(str_internals)] #![feature(test)] #![feature(trusted_len)] #![feature(try_trait_v2)] #![feature(slice_internals)] #![feature(slice_partition_dedup)] #![feature(int_log)] #![feature(iter_advance_by)] #![feature(iter_partition_in_place...
#![feature(maybe_uninit_array_assume_init)] #![feature(maybe_uninit_extra)] #![feature(maybe_uninit_write_slice)]
random_line_split
import.rs
use gpgme; use structopt; use gpgme::{data, Context, Data, ImportFlags}; use std::{error::Error, fs::File, path::PathBuf}; use structopt::StructOpt; #[derive(Debug, StructOpt)] struct
{ #[structopt(long)] /// Import from given URLs url: bool, #[structopt(short = "0")] /// URLS are delimited by a null nul: bool, #[structopt(min_values(1), parse(from_os_str))] filenames: Vec<PathBuf>, } fn main() -> Result<(), Box<dyn Error>> { let args = Cli::from_args(); let...
Cli
identifier_name
import.rs
use gpgme; use structopt; use gpgme::{data, Context, Data, ImportFlags}; use std::{error::Error, fs::File, path::PathBuf}; use structopt::StructOpt; #[derive(Debug, StructOpt)] struct Cli { #[structopt(long)] /// Import from given URLs url: bool, #[structopt(short = "0")] /// URLS are delimited by...
); } Ok(()) } fn print_import_result(result: gpgme::ImportResult) { for import in result.imports() { print!( " fpr: {} err: {:?} status:", import.fingerprint().unwrap_or("[none]"), import.result().err() ); let status = import.status(); ...
print_import_result( ctx.import(&mut data) .map_err(|e| format!("import failed {:?}", e))?,
random_line_split
import.rs
use gpgme; use structopt; use gpgme::{data, Context, Data, ImportFlags}; use std::{error::Error, fs::File, path::PathBuf}; use structopt::StructOpt; #[derive(Debug, StructOpt)] struct Cli { #[structopt(long)] /// Import from given URLs url: bool, #[structopt(short = "0")] /// URLS are delimited by...
if status.contains(ImportFlags::SECRET) { print!(" secret"); } println!(""); } println!("key import summary:"); println!(" considered: {}", result.considered()); println!(" no user id: {}", result.without_user_id()); println!(" imported: {}...
{ print!(" subkey"); }
conditional_block
uutils.rs
#![crate_name = "uutils"] #![feature(exit_status, rustc_private)] /* * This file is part of the uutils coreutils package. * * (c) Michael Gehring <mg@ebfe.org> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ extern crate getopts;...
fn main() { let umap = util_map(); let mut args : Vec<String> = env::args().collect(); // try binary name as util name. let args0 = args[0].clone(); let binary = Path::new(&args0[..]); let binary_as_util = binary.file_name().unwrap().to_str().unwrap(); match umap.get(binary_as_util) { ...
{ println!("{} {}", NAME, VERSION); println!(""); println!("Usage:"); println!(" {} [util [arguments...]]\n", NAME); println!("Currently defined functions:"); let mut utils: Vec<&str> = cmap.keys().map(|&s| s).collect(); utils.sort(); for util in utils.iter() { println!("\t{}", ...
identifier_body
uutils.rs
#![crate_name = "uutils"] #![feature(exit_status, rustc_private)] /* * This file is part of the uutils coreutils package. * * (c) Michael Gehring <mg@ebfe.org> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ extern crate getopts;...
} if binary_as_util.ends_with("uutils") || binary_as_util.starts_with("uutils") || binary_as_util.ends_with("busybox") || binary_as_util.starts_with("busybox") { // uutils can be called as either "uutils", "busybox" // "uutils-suffix" or "busybox-suffix". Not sure //...
} None => (),
random_line_split
uutils.rs
#![crate_name = "uutils"] #![feature(exit_status, rustc_private)] /* * This file is part of the uutils coreutils package. * * (c) Michael Gehring <mg@ebfe.org> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ extern crate getopts;...
() { let umap = util_map(); let mut args : Vec<String> = env::args().collect(); // try binary name as util name. let args0 = args[0].clone(); let binary = Path::new(&args0[..]); let binary_as_util = binary.file_name().unwrap().to_str().unwrap(); match umap.get(binary_as_util) { Som...
main
identifier_name
uutils.rs
#![crate_name = "uutils"] #![feature(exit_status, rustc_private)] /* * This file is part of the uutils coreutils package. * * (c) Michael Gehring <mg@ebfe.org> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ extern crate getopts;...
println!("{}: applet not found", util); env::set_exit_status(1); return } } } usage(&umap); env::set_exit_status...
{ args.remove(0); let util = &args[0][..]; match umap.get(util) { Some(&uumain) => { env::set_exit_status(uumain(args.clone())); return } None => { if &args[0][..] == "--help" { // see if the...
conditional_block
support_map_against_support_map.rs
use num::Zero; use na::{Translation, Translate}; use na; use geometry::algorithms::gjk; use geometry::algorithms::simplex::Simplex; use geometry::algorithms::johnson_simplex::JohnsonSimplex; use entities::support_map::SupportMap; use entities::support_map; use math::{Scalar, Point, Vect}; /// Distance between support...
{ let mut dir = match init_dir { None => m1.translation() - m2.translation(), // FIXME: or m2.translation - m1.translation ? Some(dir) => dir }; if dir.is_zero() { dir[0] = na::one(); } simplex.reset(support_map::cso_support_point(m1, g1, m2, g2, di...
identifier_body
support_map_against_support_map.rs
use num::Zero; use na::{Translation, Translate}; use na; use geometry::algorithms::gjk; use geometry::algorithms::simplex::Simplex; use geometry::algorithms::johnson_simplex::JohnsonSimplex; use entities::support_map::SupportMap; use entities::support_map; use math::{Scalar, Point, Vect}; /// Distance between support...
<P, M, S, G1:?Sized, G2:?Sized>( m1: &M, g1: &G1, m2: &M, g2: &G2, ...
support_map_against_support_map_with_params
identifier_name
support_map_against_support_map.rs
use num::Zero; use na::{Translation, Translate}; use na; use geometry::algorithms::gjk; use geometry::algorithms::simplex::Simplex; use geometry::algorithms::johnson_simplex::JohnsonSimplex; use entities::support_map::SupportMap; use entities::support_map; use math::{Scalar, Point, Vect}; /// Distance between support...
/// Distance between support-mapped shapes. /// /// This allows a more fine grained control other the underlying GJK algorigtm. pub fn support_map_against_support_map_with_params<P, M, S, G1:?Sized, G2:?Sized>( m1: &M, ...
}
random_line_split
stream.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use std::pin::Pin; use anyhow::Error; use async_compression::tokio::bufread::{GzipEncoder, ZstdEncoder}; use bytes::Bytes; use futures::{ ...
pub fn content_length(&self) -> Option<u64> { self.content_length } } impl<S> Stream for ResponseStream<S> where S: Stream, { type Item = S::Item; fn poll_next(self: Pin<&mut Self>, ctx: &mut Context<'_>) -> Poll<Option<Self::Item>> { self.project().inner.poll_next(ctx) } } ...
{ Self { content_length: Some(content_length), ..self } }
identifier_body
stream.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use std::pin::Pin;
use async_compression::tokio::bufread::{GzipEncoder, ZstdEncoder}; use bytes::Bytes; use futures::{ future::Either, stream::{BoxStream, Stream, StreamExt, TryStreamExt}, task::{Context, Poll}, }; use pin_project::pin_project; use tokio_util::io::{ReaderStream, StreamReader}; use crate::content_encoding::{C...
use anyhow::Error;
random_line_split
stream.rs
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use std::pin::Pin; use anyhow::Error; use async_compression::tokio::bufread::{GzipEncoder, ZstdEncoder}; use bytes::Bytes; use futures::{ ...
<S> { read: usize, yield_every: usize, #[pin] inner: S, } impl<S> YieldStream<S> { pub fn new(inner: S, yield_every: usize) -> Self { Self { read: 0, yield_every, inner, } } } impl<S, E> Stream for YieldStream<S> where S: Stream<Item = Re...
YieldStream
identifier_name
svg.mako.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
${helpers.single_keyword("dominant-baseline", """auto use-script no-change reset-size ideographic alphabetic hanging mathematical central middle text-after-edge text-before-edge""", products="gecko")} ${helpers.single_keyword("vector-effect", "none non-scaling-str...
<%namespace name="helpers" file="/helpers.mako.rs" /> <% data.new_style_struct("SVG", inherited=False, gecko_name="SVGReset") %>
random_line_split
lib.rs
extern crate clap; extern crate imageflow_helpers; extern crate imageflow_types as s; extern crate imageflow_core as fc; extern crate serde_json; use imageflow_helpers as hlp; use std::path::{Path,PathBuf}; mod cmd_build; pub mod self_test; use clap::{App, Arg, SubCommand, AppSettings}; fn artifact_source() -> ...
() -> i32 { imageflow_helpers::debug::set_panic_hook_once(); let version = s::version::one_line_version(); let app = App::new("imageflow_tool").version(version.as_ref()) .arg( Arg::with_name("capture-to").long("capture-to").takes_value(true) .help("Run whatever you're doing in a sub-proc...
main_with_exit_code
identifier_name
lib.rs
extern crate clap; extern crate imageflow_helpers; extern crate imageflow_types as s; extern crate imageflow_core as fc; extern crate serde_json; use imageflow_helpers as hlp; use std::path::{Path,PathBuf}; mod cmd_build; pub mod self_test; use clap::{App, Arg, SubCommand, AppSettings}; fn artifact_source() -> ...
{ assert!(file!().starts_with("imageflow_tool")) }
identifier_body
lib.rs
extern crate clap; extern crate imageflow_helpers; extern crate imageflow_types as s; extern crate imageflow_core as fc; extern crate serde_json; use imageflow_helpers as hlp; use std::path::{Path,PathBuf}; mod cmd_build; pub mod self_test; use clap::{App, Arg, SubCommand, AppSettings}; fn artifact_source() -> ...
else if let Some(m) = matches.subcommand_matches("v1/querystring"){ Some((m,cmd_build::JobSource::Ir4QueryString(m.value_of("command").unwrap().to_owned()), "v1/querystring")) }else{ None }; if let Some((m, source, subcommand_name)) = build_triple{ let builder = cmd_build::CmdBuild...
{ let source = if m.is_present("demo") { cmd_build::JobSource::NamedDemo(m.value_of("demo").unwrap().to_owned()) } else { cmd_build::JobSource::JsonFile(m.value_of("json").unwrap().to_owned()) }; Some((m, source, "v1/build")) }
conditional_block
lib.rs
extern crate clap; extern crate imageflow_helpers; extern crate imageflow_types as s; extern crate imageflow_core as fc; extern crate serde_json; use imageflow_helpers as hlp; use std::path::{Path,PathBuf}; mod cmd_build; pub mod self_test; use clap::{App, Arg, SubCommand, AppSettings}; fn artifact_source() -> hl...
}
random_line_split
primitive.rs
//! Allows to setup a scene with scenes in pyramidal layout, along with traits //! to help shooting rays to check for intersections use super::vec::{Vector, RFloat}; use std::default::Default; use std::f32; #[derive(Default, PartialEq, Clone, Copy, Debug)] pub struct Ray { pub pos: Vector, pub dir: Vector, }...
const NUM_ITERATIONS: usize = 10000; #[bench] fn bench_ray_sphere(b: &mut test::Bencher) { let (r1, r2, s) = setup_scene(); b.iter(|| { for _ in 0..NUM_ITERATIONS { test::black_box(s.distance_from_ray(&r1)); test::black_box(s.distance_from_ray(&r2...
assert!(s.radius != 0.0); }
random_line_split
primitive.rs
//! Allows to setup a scene with scenes in pyramidal layout, along with traits //! to help shooting rays to check for intersections use super::vec::{Vector, RFloat}; use std::default::Default; use std::f32; #[derive(Default, PartialEq, Clone, Copy, Debug)] pub struct Ray { pub pos: Vector, pub dir: Vector, }...
() -> Sphere { Sphere { center: Default::default(), radius: 1.0, } } } impl DistanceMeasure for Sphere { #[inline(always)] fn distance_from_ray(&self, r: &Ray) -> RFloat { let v = self.center - r.pos; let b = v.dot(&r.dir); let disc = b * b - ...
default
identifier_name
primitive.rs
//! Allows to setup a scene with scenes in pyramidal layout, along with traits //! to help shooting rays to check for intersections use super::vec::{Vector, RFloat}; use std::default::Default; use std::f32; #[derive(Default, PartialEq, Clone, Copy, Debug)] pub struct Ray { pub pos: Vector, pub dir: Vector, }...
hit.distance = distance; hit.pos = (ray.pos + (ray.dir.mulfed(distance) - self.center)).normalized(); } } pub trait Intersectable { /// Return intersection point of ray with item (relative to the Ray!!) fn intersect(&self, &mut Hit, ray: &Ray); } pub trait DistanceMeasure { fn distanc...
{ return; }
conditional_block
blockdev.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/. // Code to handle a single block device. use std::{fs::OpenOptions, path::Path}; use chrono::{DateTime, TimeZone, U...
match self { UnderlyingDevice::Encrypted(handle) => Some(handle), UnderlyingDevice::Unencrypted(_) => None, } } pub fn crypt_handle_mut(&mut self) -> Option<&mut CryptHandle> { match self { UnderlyingDevice::Encrypted(handle) => Some(handle), ...
UnderlyingDevice::Unencrypted(path) => &*path, } } pub fn crypt_handle(&self) -> Option<&CryptHandle> {
random_line_split
blockdev.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/. // Code to handle a single block device. use std::{fs::OpenOptions, path::Path}; use chrono::{DateTime, TimeZone, U...
fn size(&self) -> Sectors { self.total_size().sectors() } fn is_encrypted(&self) -> bool { self.encryption_info().is_some() } } impl Recordable<BaseBlockDevSave> for StratBlockDev { fn record(&self) -> BaseBlockDevSave { BaseBlockDevSave { uuid: self.uuid(), ...
{ // This cast will result in an incorrect, negative value starting in // the year 292,277,026,596. :-) Utc.timestamp(self.bda.initialization_time() as i64, 0) }
identifier_body
blockdev.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/. // Code to handle a single block device. use std::{fs::OpenOptions, path::Path}; use chrono::{DateTime, TimeZone, U...
{ dev: Device, bda: BDA, used: RangeAllocator, user_info: Option<String>, hardware_info: Option<String>, underlying_device: UnderlyingDevice, } impl StratBlockDev { /// Make a new BlockDev from the parameters. /// Allocate space for the Stratis metadata on the device. /// - dev: th...
StratBlockDev
identifier_name
meta.rs
#[doc(hidden)] #[allow(missing_debug_implementations)] #[derive(Default, Clone)] pub struct AppMeta<'b> { pub name: String, pub bin_name: Option<String>, pub author: Option<&'b str>, pub version: Option<&'b str>, pub long_version: Option<&'b str>, pub about: Option<&'b str>, pub long_about: ...
}
{ AppMeta { name: s, disp_ord: 999, ..Default::default() } }
identifier_body
meta.rs
#[doc(hidden)] #[allow(missing_debug_implementations)] #[derive(Default, Clone)] pub struct AppMeta<'b> { pub name: String, pub bin_name: Option<String>, pub author: Option<&'b str>, pub version: Option<&'b str>, pub long_version: Option<&'b str>, pub about: Option<&'b str>, pub long_about: ...
pub help_str: Option<&'b str>, pub disp_ord: usize, pub term_w: Option<usize>, pub max_w: Option<usize>, pub template: Option<&'b str>, } impl<'b> AppMeta<'b> { pub fn new() -> Self { Default::default() } pub fn with_name(s: String) -> Self { AppMeta { name: s, ...
random_line_split
meta.rs
#[doc(hidden)] #[allow(missing_debug_implementations)] #[derive(Default, Clone)] pub struct AppMeta<'b> { pub name: String, pub bin_name: Option<String>, pub author: Option<&'b str>, pub version: Option<&'b str>, pub long_version: Option<&'b str>, pub about: Option<&'b str>, pub long_about: ...
() -> Self { Default::default() } pub fn with_name(s: String) -> Self { AppMeta { name: s, disp_ord: 999, ..Default::default() } } }
new
identifier_name
issue-17074.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ assert_eq!(match 1 { X => unreachable!(), Y => unreachable!(), _ => 1 }, 1); }
identifier_body
issue-17074.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 ...
// except according to those terms. // run-pass #![allow(dead_code)] static X2: u64 =!0 as u16 as u64; static Y2: u64 =!0 as u32 as u64; const X: u64 =!0 as u16 as u64; const Y: u64 =!0 as u32 as u64; fn main() { assert_eq!(match 1 { X => unreachable!(), Y => unreachable!(), _ => 1 },...
// option. This file may not be copied, modified, or distributed
random_line_split
issue-17074.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { assert_eq!(match 1 { X => unreachable!(), Y => unreachable!(), _ => 1 }, 1); }
main
identifier_name
text_attributes.rs
// This file is part of rgtk. // // rgtk is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // rgtk is distributed in the hop...
lse { Some(TextAttributes { pointer : tmp_pointer }) } } pub fn copy_values_from(&self, src: &TextAttributes) { unsafe { ffi::gtk_text_attributes_copy_values(src.pointer, self.pointer) } } pub fn unref(&self) { unsafe { ffi::gtk_text_attributes_unref(self.pointer) }...
None } e
conditional_block
text_attributes.rs
// This file is part of rgtk. // // rgtk is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // rgtk is distributed in the hop...
pub fn _ref(&self) -> Option<TextAttributes> { let tmp_pointer = unsafe { ffi::gtk_text_attributes_ref(self.pointer) }; if tmp_pointer.is_null() { None } else { Some(TextAttributes { pointer : tmp_pointer }) } } } impl_GObjectFunctions!(TextAttributes, C...
unsafe { ffi::gtk_text_attributes_unref(self.pointer) } }
identifier_body
text_attributes.rs
// This file is part of rgtk. // // rgtk is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // rgtk is distributed in the hop...
} } pub fn copy(&self) -> Option<TextAttributes> { let tmp_pointer = unsafe { ffi::gtk_text_attributes_copy(self.pointer) }; if tmp_pointer.is_null() { None } else { Some(TextAttributes { pointer : tmp_pointer }) } } pub fn copy_values_f...
None } else { Some(TextAttributes { pointer : tmp_pointer })
random_line_split
text_attributes.rs
// This file is part of rgtk. // // rgtk is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // rgtk is distributed in the hop...
pointer: *mut ffi::C_GtkTextAttributes } impl TextAttributes { pub fn new() -> Option<TextAttributes> { let tmp_pointer = unsafe { ffi::gtk_text_attributes_new() }; if tmp_pointer.is_null() { None } else { Some(TextAttributes { pointer : tmp_pointer }) ...
xtAttributes {
identifier_name
cors.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/. */ //! A partial implementation of CORS //! For now this library is XHR-specific. //! For stuff involving `<img>`, `<...
(referer: Url, destination: Url, mode: RequestMode, method: Method, headers: Headers) -> Result<Option<CORSRequest>, ()> { if referer.scheme == destination.scheme && referer.host() == destination.host() && referer.port() == destination.port() { return Ok(No...
maybe_new
identifier_name
cors.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/. */ //! A partial implementation of CORS //! For now this library is XHR-specific. //! For stuff involving `<img>`, `<...
// Step 5 - 7 let mut header_names = vec!(); for header in self.headers.iter() { header_names.push(header.name().to_ascii_lowercase()); } header_names.sort(); preflight.headers.set(AccessControlRequestHeaders(header_names)); // Step 8 unnecessary, we...
random_line_split
cors.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/. */ //! A partial implementation of CORS //! For now this library is XHR-specific. //! For stuff involving `<img>`, `<...
fn new(mut referer: Url, destination: Url, mode: RequestMode, method: Method, headers: Headers) -> CORSRequest { match referer.scheme_data { SchemeData::Relative(ref mut data) => data.path = vec!(), _ => {} }; referer.fragment = None; referer.quer...
{ if referer.scheme == destination.scheme && referer.host() == destination.host() && referer.port() == destination.port() { return Ok(None); // Not cross-origin, proceed with a normal fetch } match destination.scheme.as_slice() { // TODO: If the requ...
identifier_body
dependency.rs
use semver::VersionReq; use core::{SourceId, Summary, PackageId}; use util::CargoResult; /// Informations about a dependency requested by a Cargo manifest. #[derive(PartialEq,Clone,Debug)] pub struct Dependency { name: String, source_id: SourceId, req: VersionReq, specified_req: Option<String>, ki...
/// Returns false if the dependency is only used to build the local package. pub fn is_transitive(&self) -> bool { match self.kind { Kind::Normal | Kind::Build => true, Kind::Development => false, } } pub fn is_build(&self) -> bool { match self.kind { Ki...
{ assert_eq!(self.source_id, *id.source_id()); assert!(self.req.matches(id.version())); self.set_version_req(VersionReq::exact(id.version())) .set_source_id(id.source_id().clone()) }
identifier_body
dependency.rs
use semver::VersionReq; use core::{SourceId, Summary, PackageId}; use util::CargoResult; /// Informations about a dependency requested by a Cargo manifest. #[derive(PartialEq,Clone,Debug)] pub struct Dependency { name: String, source_id: SourceId, req: VersionReq, specified_req: Option<String>, ki...
{ name: String, req: String } impl SerializedDependency { pub fn from_dependency(dep: &Dependency) -> SerializedDependency { SerializedDependency { name: dep.name().to_string(), req: dep.version_req().to_string() } } }
SerializedDependency
identifier_name
dependency.rs
use semver::VersionReq; use core::{SourceId, Summary, PackageId}; use util::CargoResult; /// Informations about a dependency requested by a Cargo manifest. #[derive(PartialEq,Clone,Debug)] pub struct Dependency { name: String, source_id: SourceId, req: VersionReq, specified_req: Option<String>, ki...
/// Set the source id for this dependency pub fn set_source_id(mut self, id: SourceId) -> Dependency { self.source_id = id; self } /// Set the version requirement for this dependency pub fn set_version_req(mut self, req: VersionReq) -> Dependency { self.req = req; se...
self }
random_line_split
lib.rs
/**************************************************************************** Copyright (c) 2015 Roland Ruckerbauer All Rights Reserved. This file is part of hidapi_rust. hidapi_rust is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as publish...
#[derive(Debug)] pub struct HidDeviceInfo { path: String, vendor_id: c_ushort, product_id: c_ushort, //serial_number: String, release_number: c_ushort, manufactor_string: String, product_string: String, usage_page: c_ushort, usage: c_ushort, interface_number: c_int, } pub struct...
} }
random_line_split
lib.rs
/**************************************************************************** Copyright (c) 2015 Roland Ruckerbauer All Rights Reserved. This file is part of hidapi_rust. hidapi_rust is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as publish...
} } impl Drop for HidApi { fn drop(&mut self) { unsafe { ffi::hid_exit(); hid_api_lock = false; } } } unsafe fn wcs_to_string<'a>(src: *const wchar_t) -> String { let length = ffi::wcstombs(std::ptr::null_mut(), src, 0); let mut chars = Vec::<c_char>::with_...
{ Ok(HidDevice {_hid_device: device, api: self}) }
conditional_block
lib.rs
/**************************************************************************** Copyright (c) 2015 Roland Ruckerbauer All Rights Reserved. This file is part of hidapi_rust. hidapi_rust is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as publish...
unsafe fn conv_hid_device_info(src: *mut ffi::HidDeviceInfo) -> HidDeviceInfo { HidDeviceInfo { path: std::str::from_utf8(CStr::from_ptr((*src).path).to_bytes()).unwrap().to_owned(), vendor_id: (*src).vendor_id, product_id: (*src).product_id, //serial_number: wcs_to_string((*src).s...
{ let length = ffi::wcstombs(std::ptr::null_mut(), src, 0); let mut chars = Vec::<c_char>::with_capacity(length as usize + 1); chars.set_len(length as usize + 1); let ptr = chars.as_mut_ptr(); ffi::wcstombs(ptr, src, length); chars[length as usize] = 0; std::str::from_utf8(CStr::from_ptr(ptr...
identifier_body
lib.rs
/**************************************************************************** Copyright (c) 2015 Roland Ruckerbauer All Rights Reserved. This file is part of hidapi_rust. hidapi_rust is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as publish...
(&mut self) { unsafe { ffi::hid_exit(); hid_api_lock = false; } } } unsafe fn wcs_to_string<'a>(src: *const wchar_t) -> String { let length = ffi::wcstombs(std::ptr::null_mut(), src, 0); let mut chars = Vec::<c_char>::with_capacity(length as usize + 1); chars.set...
drop
identifier_name
util.rs
use std::borrow::Cow; /// Convert string to camel case. /// /// Note: needs to be public because several macros use it. #[doc(hidden)] pub fn to_camel_case(s: &'_ str) -> Cow<'_, str>
.unwrap() .to_uppercase() .collect::<String>(); let second = &part[1..]; dest += Cow::Owned(first); dest += second; } else if i == 0 { dest = Cow::Borrowed(part); } } dest } #[test] fn test_to_camel_...
{ let mut dest = Cow::Borrowed(s); // handle '_' to be more friendly with the // _var convention for unused variables let s_iter = if let Some(stripped) = s.strip_prefix('_') { stripped } else { s } .split('_') .enumerate(); for (i, part) in s_iter { if i > ...
identifier_body
util.rs
use std::borrow::Cow; /// Convert string to camel case. /// /// Note: needs to be public because several macros use it. #[doc(hidden)] pub fn
(s: &'_ str) -> Cow<'_, str> { let mut dest = Cow::Borrowed(s); // handle '_' to be more friendly with the // _var convention for unused variables let s_iter = if let Some(stripped) = s.strip_prefix('_') { stripped } else { s } .split('_') .enumerate(); for (i, part) ...
to_camel_case
identifier_name
util.rs
use std::borrow::Cow;
/// /// Note: needs to be public because several macros use it. #[doc(hidden)] pub fn to_camel_case(s: &'_ str) -> Cow<'_, str> { let mut dest = Cow::Borrowed(s); // handle '_' to be more friendly with the // _var convention for unused variables let s_iter = if let Some(stripped) = s.strip_prefix('_') ...
/// Convert string to camel case.
random_line_split
util.rs
use std::borrow::Cow; /// Convert string to camel case. /// /// Note: needs to be public because several macros use it. #[doc(hidden)] pub fn to_camel_case(s: &'_ str) -> Cow<'_, str> { let mut dest = Cow::Borrowed(s); // handle '_' to be more friendly with the // _var convention for unused variables ...
} dest } #[test] fn test_to_camel_case() { assert_eq!(&to_camel_case("test")[..], "test"); assert_eq!(&to_camel_case("_test")[..], "test"); assert_eq!(&to_camel_case("first_second")[..], "firstSecond"); assert_eq!(&to_camel_case("first_")[..], "first"); assert_eq!(&to_camel_case("a_b_c")[...
{ dest = Cow::Borrowed(part); }
conditional_block
bloom.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/. */ //! Simple counting bloom filters. use string_cache::{Atom, Namespace}; const KEY_SIZE: uint = 12; const ARRAY_S...
(&mut self, hash: u32) -> &mut u8 { &mut self.counters[hash2(hash) as uint] } #[inline] pub fn clear(&mut self) { self.counters = [0,..ARRAY_SIZE] } #[inline] fn insert_hash(&mut self, hash: u32) { { let slot1 = self.first_mut_slot(hash); if!full...
second_mut_slot
identifier_name
bloom.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/. */ //! Simple counting bloom filters. use string_cache::{Atom, Namespace}; const KEY_SIZE: uint = 12; const ARRAY_S...
#[bench] fn hash_a_uint(b: &mut test::Bencher) { let mut i = 0u; b.iter(|| { test::black_box(hash(&i)); i += 1; }) } }
random_line_split
bloom.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/. */ //! Simple counting bloom filters. use string_cache::{Atom, Namespace}; const KEY_SIZE: uint = 12; const ARRAY_S...
} pub trait BloomHash { fn bloom_hash(&self) -> u32; } impl BloomHash for int { #[allow(exceeding_bitshifts)] #[inline] fn bloom_hash(&self) -> u32 { ((*self >> 32) ^ *self) as u32 } } impl BloomHash for uint { #[allow(exceeding_bitshifts)] #[inline] fn bloom_hash(&self) -> u...
{ self.might_contain_hash(elem.bloom_hash()) }
identifier_body
bloom.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/. */ //! Simple counting bloom filters. use string_cache::{Atom, Namespace}; const KEY_SIZE: uint = 12; const ARRAY_S...
} } /// Removes an item from the bloom filter. #[inline] pub fn remove<T:BloomHash>(&mut self, elem: &T) { self.remove_hash(elem.bloom_hash()) } #[inline] fn might_contain_hash(&self, hash: u32) -> bool { *self.first_slot(hash)!= 0 && *self.second_slot(hash)!= 0 ...
{ *slot2 -= 1 }
conditional_block
vibration_motor.rs
#![feature(used)] #![no_std] extern crate cortex_m; extern crate panic_abort; extern crate stm32f30x_hal as hal; use hal::prelude::*; use hal::stm32f30x; use hal::delay::Delay; fn
() { let cp = cortex_m::Peripherals::take().unwrap(); let dp = stm32f30x::Peripherals::take().unwrap(); let mut flash = dp.FLASH.constrain(); let mut rcc = dp.RCC.constrain(); let clocks = rcc.cfgr.freeze(&mut flash.acr); let mut gpioa = dp.GPIOA.split(&mut rcc.ahb); let mut motor = gpio...
main
identifier_name
vibration_motor.rs
#![feature(used)] #![no_std] extern crate cortex_m; extern crate panic_abort; extern crate stm32f30x_hal as hal; use hal::prelude::*; use hal::stm32f30x; use hal::delay::Delay; fn main()
motor.set_low(); delay.delay_ms(1_000_u16); } }
{ let cp = cortex_m::Peripherals::take().unwrap(); let dp = stm32f30x::Peripherals::take().unwrap(); let mut flash = dp.FLASH.constrain(); let mut rcc = dp.RCC.constrain(); let clocks = rcc.cfgr.freeze(&mut flash.acr); let mut gpioa = dp.GPIOA.split(&mut rcc.ahb); let mut motor = gpioa ...
identifier_body
vibration_motor.rs
#![feature(used)] #![no_std]
use hal::prelude::*; use hal::stm32f30x; use hal::delay::Delay; fn main() { let cp = cortex_m::Peripherals::take().unwrap(); let dp = stm32f30x::Peripherals::take().unwrap(); let mut flash = dp.FLASH.constrain(); let mut rcc = dp.RCC.constrain(); let clocks = rcc.cfgr.freeze(&mut flash.acr); ...
extern crate cortex_m; extern crate panic_abort; extern crate stm32f30x_hal as hal;
random_line_split
mod.rs
/* Precached - A Linux process monitor and pre-caching daemon Copyright (C) 2017-2020 the precached developers
Precached 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 later version. Precached is distributed in the hope that it will be useful, ...
This file is part of precached.
random_line_split
tree.rs
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use anyhow::Error; use edenapi_types::TreeEntry as EdenApiTreeEntry; use minibytes::Bytes; use types::{Key, Parents}; use crate::{datastore...
(&self) -> Option<&Key> { self.key.as_ref() } /// The tree content blob in the serialized tree-manifest format. pub fn content(&self) -> Option<&Bytes> { self.raw_content.as_ref() } }
key
identifier_name
tree.rs
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use anyhow::Error; use edenapi_types::TreeEntry as EdenApiTreeEntry; use minibytes::Bytes; use types::{Key, Parents}; use crate::{datastore...
} impl TryFrom<EdenApiTreeEntry> for StoreTree { type Error = Error; fn try_from(v: EdenApiTreeEntry) -> Result<Self, Self::Error> { // TODO(meyer): Optimize this to remove unnecessary clones. let raw_content = v.data_checked()?.into(); Ok(StoreTree { key: Some(v.key().clo...
{ let raw_content = v.content()?; let key = v.key().clone(); let entry_metadata = v.metadata().clone(); Ok(StoreTree { key: Some(key), parents: None, entry_metadata: Some(entry_metadata), raw_content: Some(raw_content), }) }
identifier_body
tree.rs
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This software may be used and distributed according to the terms of the * GNU General Public License version 2. */ use anyhow::Error; use edenapi_types::TreeEntry as EdenApiTreeEntry; use minibytes::Bytes;
#[derive(Clone, Debug)] pub struct StoreTree { key: Option<Key>, #[allow(dead_code)] parents: Option<Parents>, raw_content: Option<Bytes>, #[allow(dead_code)] entry_metadata: Option<Metadata>, } impl TryFrom<Entry> for StoreTree { type Error = Error; fn try_from(mut v: Entry) -> Resul...
use types::{Key, Parents}; use crate::{datastore::Metadata, indexedlogdatastore::Entry};
random_line_split
dialer.rs
use std::io::Cursor; use std::str; use byteorder::{ByteOrder, NativeEndian, NetworkEndian, ReadBytesExt}; use common::dialer::Dialer; use common::utils::current_timestamp; #[derive(Debug)] pub enum Configuration { Hainan, } #[derive(Debug)] pub struct SingleNetDialer { share_key: String, secret_key: St...
SingleNetDialer::new(config.share_key(), config.secret_key(), config.key_table()) } } #[test] fn test_hash_key() { let str1 = "123456".to_string(); let str2 = "1234567".to_string(); let hash1 = SingleNetDialer::calc_hash(str1.as_bytes()); let hash2 = SingleNetDialer::calc_hash(str2.as_bytes...
impl Dialer for SingleNetDialer { type C = Configuration; fn load_from_config(config: Self::C) -> Self {
random_line_split
dialer.rs
use std::io::Cursor; use std::str; use byteorder::{ByteOrder, NativeEndian, NetworkEndian, ReadBytesExt}; use common::dialer::Dialer; use common::utils::current_timestamp; #[derive(Debug)] pub enum Configuration { Hainan, } #[derive(Debug)] pub struct SingleNetDialer { share_key: String, secret_key: St...
hash_data.extend_from_slice(&first_hash_bytes); hash_data.extend(self.secret_key.as_bytes()); second_hash = Self::calc_hash(&hash_data); } let mut scheduled_table: Vec<u8> = Vec::with_capacity(8); { let time_now_high = (time_now >> 16) as u16; ...
{ let username = username.to_uppercase(); let time_now = timestamp.unwrap_or_else(current_timestamp); let first_hash: u16; { let mut time_now_bytes = [0u8; 4]; NetworkEndian::write_u32(&mut time_now_bytes, time_now); let mut hash_data: Vec<u8> = Vec::...
identifier_body
dialer.rs
use std::io::Cursor; use std::str; use byteorder::{ByteOrder, NativeEndian, NetworkEndian, ReadBytesExt}; use common::dialer::Dialer; use common::utils::current_timestamp; #[derive(Debug)] pub enum Configuration { Hainan, } #[derive(Debug)] pub struct SingleNetDialer { share_key: String, secret_key: St...
(&self, username: &str, timestamp: Option<u32>) -> String { let username = username.to_uppercase(); let time_now = timestamp.unwrap_or_else(current_timestamp); let first_hash: u16; { let mut time_now_bytes = [0u8; 4]; NetworkEndian::write_u32(&mut time_now_bytes,...
encrypt_account
identifier_name
dump-adt-brace-struct.rs
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
#[rustc_dump_user_substs] fn main() { SomeStruct { t: 22 }; // Nothing given, no annotation. SomeStruct::<_> { t: 22 }; // Nothing interesting given, no annotation. SomeStruct::<u32> { t: 22 }; //~ ERROR [u32] }
random_line_split
dump-adt-brace-struct.rs
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { SomeStruct { t: 22 }; // Nothing given, no annotation. SomeStruct::<_> { t: 22 }; // Nothing interesting given, no annotation. SomeStruct::<u32> { t: 22 }; //~ ERROR [u32] }
main
identifier_name
lib.rs
extern crate walkdir; extern crate phf_codegen; extern crate flate2; use std::{env, fmt, io}; use std::borrow::{Borrow, Cow}; use std::collections::HashMap; use std::fs::{self, File}; use std::io::{BufReader, BufWriter, Write}; use std::path::{Path, PathBuf}; use walkdir::WalkDir; use flate2::write::GzEncoder; #[de...
(path: &str) -> Cow<str> { Cow::Borrowed(path) } impl IncludeDir { /// Add a single file to the binary. /// With Gzip compression, the file will be encoded to OUT_DIR first. /// For chaining, it's not sensible to return a Result. If any to-be-included /// files can't be found, or encoded, this func...
as_key
identifier_name
lib.rs
extern crate walkdir; extern crate phf_codegen; extern crate flate2; use std::{env, fmt, io}; use std::borrow::{Borrow, Cow}; use std::collections::HashMap; use std::fs::{self, File}; use std::io::{BufReader, BufWriter, Write}; use std::path::{Path, PathBuf}; use walkdir::WalkDir; use flate2::write::GzEncoder; #[de...
} pub struct IncludeDir { files: HashMap<String, (Compression, PathBuf)>, name: String, manifest_dir: PathBuf } pub fn start(static_name: &str) -> IncludeDir { IncludeDir { files: HashMap::new(), name: static_name.to_owned(), manifest_dir: Path::new(&env::var("CARGO_MANIFEST_D...
{ match *self { Compression::None => fmt.write_str("None"), Compression::Gzip => fmt.write_str("Gzip"), } }
identifier_body
lib.rs
extern crate walkdir; extern crate phf_codegen; extern crate flate2; use std::{env, fmt, io}; use std::borrow::{Borrow, Cow}; use std::collections::HashMap; use std::fs::{self, File}; use std::io::{BufReader, BufWriter, Write}; use std::path::{Path, PathBuf}; use walkdir::WalkDir; use flate2::write::GzEncoder; #[de...
} #[cfg(windows)] fn as_key(path: &str) -> Cow<str> { Cow::Owned(path.replace("\\", "/")) } #[cfg(not(windows))] fn as_key(path: &str) -> Cow<str> { Cow::Borrowed(path) } impl IncludeDir { /// Add a single file to the binary. /// With Gzip compression, the file will be encoded to OUT_DIR first. /...
files: HashMap::new(), name: static_name.to_owned(), manifest_dir: Path::new(&env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR is not set")).to_owned() }
random_line_split
thrift_build.rs
// @generated by autocargo use std::env; use std::fs; use std::path::Path; use thrift_compiler::Config; #[rustfmt::skip] fn main() { // Rerun if this gets rewritten. println!("cargo:rerun-if-changed=thrift_build.rs"); let out_dir = env::var_os("OUT_DIR").expect("OUT_DIR env not provided"); let out_di...
let include_srcs = vec![ ]; conf.include_srcs(include_srcs); conf }; conf .run(&[ "../test_thrift.thrift" ]) .expect("Failed while running thrift compilation"); }
{ conf.options(options); }
conditional_block
thrift_build.rs
// @generated by autocargo use std::env; use std::fs; use std::path::Path; use thrift_compiler::Config; #[rustfmt::skip] fn main() { // Rerun if this gets rewritten. println!("cargo:rerun-if-changed=thrift_build.rs"); let out_dir = env::var_os("OUT_DIR").expect("OUT_DIR env not provided"); let out_di...
let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not provided"); let cargo_manifest_dir: &Path = cargo_manifest_dir.as_ref(); let base_path = cargo_manifest_dir .join(path_from_manifest_to_base) .canonicalize() .ex...
let path_from_manifest_to_base: &Path = "../../../../../..".as_ref();
random_line_split
thrift_build.rs
// @generated by autocargo use std::env; use std::fs; use std::path::Path; use thrift_compiler::Config; #[rustfmt::skip] fn
() { // Rerun if this gets rewritten. println!("cargo:rerun-if-changed=thrift_build.rs"); let out_dir = env::var_os("OUT_DIR").expect("OUT_DIR env not provided"); let out_dir: &Path = out_dir.as_ref(); fs::write( out_dir.join("cratemap"), "test_thrift crate", ).expect("Failed to...
main
identifier_name
thrift_build.rs
// @generated by autocargo use std::env; use std::fs; use std::path::Path; use thrift_compiler::Config; #[rustfmt::skip] fn main()
.canonicalize() .expect("Failed to canonicalize base_path"); // TODO: replace canonicalize() with std::path::absolute() when // https://github.com/rust-lang/rust/pull/91673 is available (~Rust 1.60) // and remove this block. #[cfg(windows)] let base_path = P...
{ // Rerun if this gets rewritten. println!("cargo:rerun-if-changed=thrift_build.rs"); let out_dir = env::var_os("OUT_DIR").expect("OUT_DIR env not provided"); let out_dir: &Path = out_dir.as_ref(); fs::write( out_dir.join("cratemap"), "test_thrift crate", ).expect("Failed to wr...
identifier_body
cci_class_4.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
// except according to those terms. pub mod kitties { pub struct cat { meows : uint, pub how_hungry : int, pub name : String, } impl cat { pub fn speak(&mut self) { self.meow(); } pub fn eat(&mut self) -> bool { if self.how_hungry > 0 { ...
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed
random_line_split
cci_class_4.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 ...
} } pub fn cat(in_x : uint, in_y : int, in_name: String) -> cat { cat { meows: in_x, how_hungry: in_y, name: in_name } } }
{ self.how_hungry += 1; }
conditional_block
cci_class_4.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 ...
(&mut self) { self.meow(); } pub fn eat(&mut self) -> bool { if self.how_hungry > 0 { println!("OM NOM NOM"); self.how_hungry -= 2; return true; } else { println!("Not hungry!"); return false; } ...
speak
identifier_name
mod.rs
/// VGA text buffer module. pub mod color; #[cfg(test)] mod test; pub use self::color::Color; pub use self::color::VgaColorCode; pub use core::ptr::Unique; pub use spin::Mutex; /// Height of the VGA text buffer. pub const BUFFER_HEIGHT: usize = 25; /// Width of the VGA text buffer. pub const BUFFER_WIDTH: usize = ...
/// Scrolls the entire screen by setting each row to be the row below it. This destroys the /// first 80 characters of data that existed before this function was called. This function /// also clears the final row of the text buffer (the last 80 characters of data). Afterwards, /// we set the `column_...
{ unsafe { self.buffer.get_mut() } }
identifier_body
mod.rs
/// VGA text buffer module. pub mod color; #[cfg(test)] mod test; pub use self::color::Color; pub use self::color::VgaColorCode; pub use core::ptr::Unique; pub use spin::Mutex; /// Height of the VGA text buffer. pub const BUFFER_HEIGHT: usize = 25; /// Width of the VGA text buffer. pub const BUFFER_WIDTH: usize = ...
/// # Arguments /// /// * `row_position` - The row position to be set to. /// * `column_position` - The column position to be set to. /// /// # Invariants /// /// * 0 <= `self.row_position` < `BUFFER_HEIGHT` /// * 0 <= `self.column_position` < `BUFFER_WIDTH` pub fn set_position(&...
/// Sets the position of the cursor. If the arguments are outside of the VGA buffer bounds /// (`BUFFER_HEIGHT` and `BUFFER_WIDTH` are the respective max values, while 0 is the min value /// for both), then we just default to the closest valid value. ///
random_line_split
mod.rs
/// VGA text buffer module. pub mod color; #[cfg(test)] mod test; pub use self::color::Color; pub use self::color::VgaColorCode; pub use core::ptr::Unique; pub use spin::Mutex; /// Height of the VGA text buffer. pub const BUFFER_HEIGHT: usize = 25; /// Width of the VGA text buffer. pub const BUFFER_WIDTH: usize = ...
{ chars: [[ScreenChar; BUFFER_WIDTH]; BUFFER_HEIGHT], } /// VGA text buffer writer. Use this struct for rudimentary writes to the VGA text buffer. /// /// This struct keeps track of the current row and current column of the cursor, as well as the /// current color code. It also owns the pointer to the VGA text bu...
Buffer
identifier_name
attr.rs
not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! Parsed representations of [DOM attributes][attr]. //! //! [attr]: https://dom.spec.whatwg.org/#interface-attr use {Atom, Prefix, Namespace, LocalName}; use app_units::Au; use cssparser::{self, Color, RGBA}; use euclid::num::...
/// Assumes the `AttrValue` is a `Dimension` and returns its value /// /// ## Panics /// /// Panics if the `AttrValue` is not a `Dimension` pub fn as_dimension(&self) -> &LengthOrPercentageOrAuto { match *self { AttrValue::Dimension(_, ref l) => l, _ => panic!("...
{ match *self { AttrValue::Length(_, ref length) => length.as_ref(), _ => panic!("Length not found"), } }
identifier_body
attr.rs
was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! Parsed representations of [DOM attributes][attr]. //! //! [attr]: https://dom.spec.whatwg.org/#interface-attr use {Atom, Prefix, Namespace, LocalName}; use app_units::Au; use cssparser::{self, Color, RGBA}; use euclid::n...
// Step 10. let mut new_input = Vec::new(); for ch in input.chars() { if hex(ch).is_ok() { new_input.push(ch as u8) } else { new_input.push(b'0') } } let mut input = new_input; // Step 11. while input.is_empty() || (input.len() % 3)!= 0 { ...
}
random_line_split
attr.rs
not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! Parsed representations of [DOM attributes][attr]. //! //! [attr]: https://dom.spec.whatwg.org/#interface-attr use {Atom, Prefix, Namespace, LocalName}; use app_units::Au; use cssparser::{self, Color, RGBA}; use euclid::num::...
(&self) -> &LengthOrPercentageOrAuto { match *self { AttrValue::Dimension(_, ref l) => l, _ => panic!("Dimension not found"), } } /// Assumes the `AttrValue` is a `ResolvedUrl` and returns its value. /// /// ## Panics /// /// Panics if the `AttrValue` is ...
as_dimension
identifier_name
attr.rs
not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! Parsed representations of [DOM attributes][attr]. //! //! [attr]: https://dom.spec.whatwg.org/#interface-attr use {Atom, Prefix, Namespace, LocalName}; use app_units::Au; use cssparser::{self, Color, RGBA}; use euclid::num::...
; let input = trimmed.chars().skip(value_digits + chars_skipped).peekable(); let (mut value, fraction_digits) = read_fraction(input, divisor, value); let input = trimmed.chars().skip(value_digits + chars_skipped + fraction_digits).peekable(); if let Some(exp) = read_exponent(input) { value *...
{ let (read_val, read_digits) = read_numbers(input); (value * read_val.and_then(|result| result.to_f64()).unwrap_or(1f64), read_digits) }
conditional_block
mod.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 ...
pub mod prelude { #[doc(no_inline)] pub use super::io::{RawFd, AsRawFd, FromRawFd}; #[doc(no_inline)] #[stable(feature = "rust1", since = "1.0.0")] pub use super::ffi::{OsStrExt, OsStringExt}; #[doc(no_inline)] pub use super::fs::{PermissionsExt, OpenOptionsExt, MetadataExt, FileTypeExt}; #[...
/// /// Includes all extension traits, and some important type definitions. #[stable(feature = "rust1", since = "1.0.0")]
random_line_split
winefs.rs
// Licensed under the Apache License, Version 2.0 // <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. // All files in the project carrying such notice may not be copied, modified, or distributed // except according ...
STRUCT!{struct EFS_DECRYPTION_STATUS_INFO { dwDecryptionError: DWORD, dwHashOffset: DWORD, cbHash: DWORD, }} pub type PEFS_DECRYPTION_STATUS_INFO = *mut EFS_DECRYPTION_STATUS_INFO; STRUCT!{struct EFS_ENCRYPTION_STATUS_INFO { bHasCurrentKey: BOOL, dwEncryptionError: DWORD, }} pub type PEFS_ENCRYPTIO...
{ v == EFS_COMPATIBILITY_VERSION_PFILE_PROTECTOR && subV == EFS_PFILE_SUBVER_APPX }
identifier_body
winefs.rs
// Licensed under the Apache License, Version 2.0 // <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. // All files in the project carrying such notice may not be copied, modified, or distributed // except according ...
(v: DWORD) -> bool { v == EFS_COMPATIBILITY_VERSION_NCRYPT_PROTECTOR || v == EFS_COMPATIBILITY_VERSION_PFILE_PROTECTOR } pub const EFS_SUBVER_UNKNOWN: DWORD = 0; pub const EFS_EFS_SUBVER_EFS_CERT: DWORD = 1; pub const EFS_PFILE_SUBVER_RMS: DWORD = 2; pub const EFS_PFILE_SUBVER_APPX: DWORD = 3; STRUCT!{struc...
EFS_IS_DESCRIPTOR_VERSION
identifier_name
winefs.rs
// Licensed under the Apache License, Version 2.0 // <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. // All files in the project carrying such notice may not be copied, modified, or distributed // except according ...
pHash: PEFS_HASH_BLOB, lpDisplayInformation: LPWSTR, }} pub type PENCRYPTION_CERTIFICATE_HASH = *mut ENCRYPTION_CERTIFICATE_HASH; STRUCT!{struct ENCRYPTION_CERTIFICATE_HASH_LIST { nCert_Hash: DWORD, pUsers: *mut PENCRYPTION_CERTIFICATE_HASH, }} pub type PENCRYPTION_CERTIFICATE_HASH_LIST = *mut ENCRYPTIO...
pUserSid: *mut SID,
random_line_split
timings.rs
//! Tests for -Ztimings. use cargo_test_support::project; use cargo_test_support::registry::Package; #[cargo_test] fn timings_works()
p.cargo("build --all-targets -Ztimings") .masquerade_as_nightly_cargo() .with_stderr_unordered( "\ [UPDATING] [..] [DOWNLOADING] crates... [DOWNLOADED] dep v0.1.0 [..] [COMPILING] dep v0.1.0 [COMPILING] foo v0.1.0 [..] [COMPLETED] dep v0.1.0 in [..]s [COMPLETED] foo v0.1.0 in [..]s [COMPL...
{ Package::new("dep", "0.1.0").publish(); let p = project() .file( "Cargo.toml", r#" [package] name = "foo" version = "0.1.0" [dependencies] dep = "0.1" "#, ) .file("src/lib.rs", "") ...
identifier_body
timings.rs
//! Tests for -Ztimings. use cargo_test_support::project; use cargo_test_support::registry::Package; #[cargo_test] fn
() { Package::new("dep", "0.1.0").publish(); let p = project() .file( "Cargo.toml", r#" [package] name = "foo" version = "0.1.0" [dependencies] dep = "0.1" "#, ) .file("src/lib.rs", "") ...
timings_works
identifier_name
timings.rs
//! Tests for -Ztimings. use cargo_test_support::project; use cargo_test_support::registry::Package; #[cargo_test] fn timings_works() { Package::new("dep", "0.1.0").publish(); let p = project() .file( "Cargo.toml", r#" [package] name = "foo" ...
) .run(); p.cargo("clean").run(); p.cargo("test -Ztimings") .masquerade_as_nightly_cargo() .run(); p.cargo("clean").run(); p.cargo("check -Ztimings") .masquerade_as_nightly_cargo() .run(); p.cargo("clean").run(); p.cargo("doc -Ztimings").masquerad...
",
random_line_split
literals.rs
use common; use ast; use io; pub fn parse_integer(source: &mut io::SourceFlexIterator) -> common::Status<ast::Token> { assert!(source.peek(0).is_some()); assert!(match source.peek(0).unwrap() { '0'...'9' => true, _ => false, }); let location = source.location(); let mut value = St...
location: Some(source.location()), message: format!("Invalid escape sequence '\\{}'.", next_chr), }); break; } } chr = next_chr; ...
{ assert!(source.peek(0).is_some()); assert_eq!(source.peek(0).unwrap(), '"'); let mut error = None; let location = source.location(); let mut value = String::new(); source.next(); while let Some(mut chr) = source.peek(0) { if chr != '"' { if chr == '\\' { ...
identifier_body
literals.rs
use common; use ast; use io; pub fn parse_integer(source: &mut io::SourceFlexIterator) -> common::Status<ast::Token> { assert!(source.peek(0).is_some()); assert!(match source.peek(0).unwrap() { '0'...'9' => true, _ => false, }); let location = source.location(); let mut value = St...
source.next(); } else { break; } } let token = ast::Token::new(ast::TokenKind::String, value, location); error = error.or(match source.peek(0) { None => { Some(common::Error { location: Some(token.location), messag...
{ if chr == '\\' { if let Some(next_chr) = source.peek(1) { match next_chr { 'n' | 'r' | 't' | '"' | '\\' => { value.push(chr); source.next(); } ...
conditional_block
literals.rs
use common; use ast; use io; pub fn parse_integer(source: &mut io::SourceFlexIterator) -> common::Status<ast::Token> { assert!(source.peek(0).is_some()); assert!(match source.peek(0).unwrap() { '0'...'9' => true, _ => false, }); let location = source.location(); let mut value = St...
(source: &mut io::SourceFlexIterator) -> common::Status<ast::Token> { assert!(source.peek(0).is_some()); assert_eq!(source.peek(0).unwrap(), '"'); let mut error = None; let location = source.location(); let mut value = String::new(); source.next(); while let Some(mut chr) = source.peek(0) ...
parse_string
identifier_name
literals.rs
use common; use ast; use io; pub fn parse_integer(source: &mut io::SourceFlexIterator) -> common::Status<ast::Token> { assert!(source.peek(0).is_some()); assert!(match source.peek(0).unwrap() { '0'...'9' => true, _ => false, }); let location = source.location(); let mut value = St...
pub fn parse_string(source: &mut io::SourceFlexIterator) -> common::Status<ast::Token> { assert!(source.peek(0).is_some()); assert_eq!(source.peek(0).unwrap(), '"'); let mut error = None; let location = source.location(); let mut value = String::new(); source.next(); while let Some(mut ch...
result: token, error: error, } }
random_line_split
model.rs
use geometry::Vector3D; use std::io::{BufReader,BufRead}; use std::fs::File; use std::path::Path; use tgacanvas::TgaCanvas; use canvas::Canvas; pub struct Model { pub vertices: Vec<Vector3D<f32>>, pub faces : Vec<[[i32; 3]; 3]>, pub uv : Vec<[f32; 2]>, pub diffusemap : TgaCanvas, } impl Model { pu...
(&self, iface: usize, nvert: usize) -> Vector3D<i32> { let idx = self.faces[iface][nvert][1] as usize; return Vector3D::new(self.uv[idx][0] * self.diffusemap.xsize() as f32, self.uv[idx][1] * self.diffusemap.ysize() as f32, 0.0).to::<i32>(); } }
uv
identifier_name
model.rs
use geometry::Vector3D; use std::io::{BufReader,BufRead}; use std::fs::File; use std::path::Path; use tgacanvas::TgaCanvas; use canvas::Canvas; pub struct Model { pub vertices: Vec<Vector3D<f32>>, pub faces : Vec<[[i32; 3]; 3]>, pub uv : Vec<[f32; 2]>, pub diffusemap : TgaCanvas, } impl Model { pu...
face[i][j] = num.parse::<i32>().unwrap() - 1; j += 1; } debug!("face[{}] = [{}, {}, {}]", i, face[i][0], face[i][1], face[i][2]); } faces.push(face); } else if line.starts_with("vt ") { ...
{ let path = Path::new(file_path); let file = BufReader::new(File::open(&path).unwrap()); let mut vertices = Vec::new(); let mut faces = Vec::new(); let mut uv = Vec::new(); for line in file.lines() { let line = line.unwrap(); if line.starts_with("...
identifier_body
model.rs
use geometry::Vector3D; use std::io::{BufReader,BufRead}; use std::fs::File; use std::path::Path; use tgacanvas::TgaCanvas; use canvas::Canvas; pub struct Model { pub vertices: Vec<Vector3D<f32>>, pub faces : Vec<[[i32; 3]; 3]>, pub uv : Vec<[f32; 2]>, pub diffusemap : TgaCanvas, } impl Model { pu...
} let texture_path = file_path.rsplitn(2, '.').last().unwrap().to_string() + "_diffuse.tga"; info!("loading texture from path: {}", texture_path); Model { vertices: vertices, faces: faces, uv: uv, diffusemap: TgaCanvas::read(texture_path.s...
{ let words: Vec<&str> = line.split_whitespace().collect(); uv.push([words[1].parse().unwrap(), words[2].parse().unwrap()]); debug!("uv: [{}, {}]", uv.last().unwrap()[0], uv.last().unwrap()[1]); }
conditional_block
model.rs
use geometry::Vector3D; use std::io::{BufReader,BufRead}; use std::fs::File; use std::path::Path; use tgacanvas::TgaCanvas; use canvas::Canvas; pub struct Model { pub vertices: Vec<Vector3D<f32>>, pub faces : Vec<[[i32; 3]; 3]>, pub uv : Vec<[f32; 2]>, pub diffusemap : TgaCanvas, } impl Model { pu...
} debug!("face[{}] = [{}, {}, {}]", i, face[i][0], face[i][1], face[i][2]); } faces.push(face); } else if line.starts_with("vt ") { let words: Vec<&str> = line.split_whitespace().collect(); uv.push([words...
random_line_split
issue-22560.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { }
main
identifier_name
issue-22560.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn main() { }
//~^ ERROR the type parameter `RHS` must be explicitly specified in an object type because its default value `Self` references the type `Self` //~^^ ERROR the value of the associated type `Output` (from the trait `core::ops::Add`) must be specified [E0191] Sub; //~^ ERROR...
random_line_split