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
vec-slices.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...
let empty: &[i64] = &[]; let singleton: &[i64] = &[1]; let multiple: &[i64] = &[2, 3, 4, 5]; let slice_of_slice = &multiple[1..3]; let padded_tuple: &[(i32, i16)] = &[(6, 7), (8, 9)]; let padded_struct: &[AStruct] = &[ AStruct { x: 10, y: 11, z: 12 }, AStruct { x: 13, y: 14, z:...
random_line_split
vec-slices.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...
() { let empty: &[i64] = &[]; let singleton: &[i64] = &[1]; let multiple: &[i64] = &[2, 3, 4, 5]; let slice_of_slice = &multiple[1..3]; let padded_tuple: &[(i32, i16)] = &[(6, 7), (8, 9)]; let padded_struct: &[AStruct] = &[ AStruct { x: 10, y: 11, z: 12 }, AStruct { x: 13, y: 1...
main
identifier_name
hybrid.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 crate::AppendCommits; use crate::DescribeBackend; use crate::HgCommit; use crate::HgCommits; use crate::ParentlessHgCommit; use crate::Re...
} #[async_trait::async_trait] impl ReadCommitText for HybridCommits { async fn get_commit_raw_text_list(&self, vertexes: &[Vertex]) -> Result<Vec<Bytes>> { let vertexes: Vec<Vertex> = vertexes.to_vec(); let stream = self.stream_commit_raw_text(Box::pin(stream::iter(vertexes.into_iter()...
{ if let Some(revlog) = self.revlog.as_mut() { revlog.flush_commit_data().await?; } self.commits.flush_commit_data().await?; Ok(()) }
identifier_body
hybrid.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 crate::AppendCommits; use crate::DescribeBackend; use crate::HgCommit; use crate::HgCommits; use crate::ParentlessHgCommit; use crate::Re...
(&mut self, set: Set) -> Result<()> { if let Some(revlog) = self.revlog.as_mut() { revlog.strip_commits(set.clone()).await?; } self.commits.strip_commits(set).await?; Ok(()) } } struct Resolver { client: Arc<dyn EdenApi>, zstore: Arc<RwLock<Zstore>>, reponame...
strip_commits
identifier_name
hybrid.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 crate::AppendCommits; use crate::DescribeBackend; use crate::HgCommit; use crate::HgCommits; use crate::ParentlessHgCommit; use crate::Re...
fn explain_internals(&self, w: &mut dyn io::Write) -> io::Result<()> { self.commits.explain_internals(w) } }
self.commits.commits_path.display(), revlog_path, revlog_usage, ) }
random_line_split
hybrid.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 crate::AppendCommits; use crate::DescribeBackend; use crate::HgCommit; use crate::HgCommits; use crate::ParentlessHgCommit; use crate::Re...
let bytes = &e.revlog_data[Id20::len() * 2..]; let input_output = ( Vertex::copy_from(e.hgid.as_ref()), Bytes::copy_from_slice(&bytes), ); Ok(input_output) }); Ok(Box::pin(commits) as BoxStream<'_, _>) } fn retry_e...
{ anyhow::bail!( "server returned commit-text pair ({}, {:?}) has mismatched SHA1: {}", e.hgid.to_hex(), e.revlog_data, written_id.to_hex(), ); }
conditional_block
regression.rs
use random; use random::Source; use std::error::Error; use std::fs::File; use std::io::Read; use std::path::Path; use std::result::Result; use tensorflow::Code; use tensorflow::Graph; use tensorflow::ImportGraphDefOptions; use tensorflow::Session; use tensorflow::SessionOptions; use tensorflow::SessionRunArgs; use tens...
if!Path::new(filename).exists() { return Err(Box::new( Status::new_set( Code::NotFound, &format!( "Run 'python regression.py' to generate \ {} and try again.", filename ), ) ...
static ALLOCATOR: std::alloc::System = std::alloc::System; fn main() -> Result<(), Box<dyn Error>> { let filename = "examples/regression/model.pb"; // y = w * x + b
random_line_split
regression.rs
use random; use random::Source; use std::error::Error; use std::fs::File; use std::io::Read; use std::path::Path; use std::result::Result; use tensorflow::Code; use tensorflow::Graph; use tensorflow::ImportGraphDefOptions; use tensorflow::Session; use tensorflow::SessionOptions; use tensorflow::SessionRunArgs; use tens...
// Generate some test data. let w = 0.1; let b = 0.3; let num_points = 100; let steps = 201; let mut rand = random::default(); let mut x = Tensor::new(&[num_points as u64]); let mut y = Tensor::new(&[num_points as u64]); for i in 0..num_points { x[i] = (2.0 * rand.read::<f6...
{ return Err(Box::new( Status::new_set( Code::NotFound, &format!( "Run 'python regression.py' to generate \ {} and try again.", filename ), ) .unwrap(), )); ...
conditional_block
regression.rs
use random; use random::Source; use std::error::Error; use std::fs::File; use std::io::Read; use std::path::Path; use std::result::Result; use tensorflow::Code; use tensorflow::Graph; use tensorflow::ImportGraphDefOptions; use tensorflow::Session; use tensorflow::SessionOptions; use tensorflow::SessionRunArgs; use tens...
let steps = 201; let mut rand = random::default(); let mut x = Tensor::new(&[num_points as u64]); let mut y = Tensor::new(&[num_points as u64]); for i in 0..num_points { x[i] = (2.0 * rand.read::<f64>() - 1.0) as f32; y[i] = w * x[i] + b; } // Load the computation graph defi...
{ let filename = "examples/regression/model.pb"; // y = w * x + b if !Path::new(filename).exists() { return Err(Box::new( Status::new_set( Code::NotFound, &format!( "Run 'python regression.py' to generate \ {} and try a...
identifier_body
regression.rs
use random; use random::Source; use std::error::Error; use std::fs::File; use std::io::Read; use std::path::Path; use std::result::Result; use tensorflow::Code; use tensorflow::Graph; use tensorflow::ImportGraphDefOptions; use tensorflow::Session; use tensorflow::SessionOptions; use tensorflow::SessionRunArgs; use tens...
() -> Result<(), Box<dyn Error>> { let filename = "examples/regression/model.pb"; // y = w * x + b if!Path::new(filename).exists() { return Err(Box::new( Status::new_set( Code::NotFound, &format!( "Run 'python regression.py' to generate \ ...
main
identifier_name
self-in-default-method.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 self_owned(~self, arg1: int, arg2: int) -> int { zzz(); arg1 + arg2 } fn self_managed(@self, arg1: int, arg2: int) -> int { zzz(); arg1 + arg2 } } impl Trait for Struct {} fn main() { let stack = Struct { x: 100 }; let _ = stack.self_by_ref(-1, -2); le...
{ zzz(); arg1 + arg2 }
identifier_body
self-in-default-method.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 ...
// debugger:continue // MANAGED BY VAL // debugger:finish // debugger:print self // check:$19 = {x = 300} // debugger:print arg1 // check:$20 = -13 // debugger:print arg2 // check:$21 = -14 // debugger:continue // MANAGED SELF // debugger:finish // debugger:print self->val // check:$22 = {x = 300} // debugger:print a...
// debugger:print arg1 // check:$17 = -11 // debugger:print arg2 // check:$18 = -12
random_line_split
self-in-default-method.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 ...
(self, arg1: int, arg2: int) -> int { zzz(); arg1 + arg2 } fn self_owned(~self, arg1: int, arg2: int) -> int { zzz(); arg1 + arg2 } fn self_managed(@self, arg1: int, arg2: int) -> int { zzz(); arg1 + arg2 } } impl Trait for Struct {} fn main() { ...
self_by_val
identifier_name
transmute_ref_to_ref.rs
use super::{TRANSMUTE_BYTES_TO_STR, TRANSMUTE_PTR_TO_PTR}; use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_and_then}; use clippy_utils::source::snippet; use clippy_utils::sugg; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::{Expr, Mutability}; use rustc_lint::LateContext; use rust...
"consider using", format!( "std::str::from_utf8{}({}).unwrap()", postfix, snippet(cx, args[0].span, ".."), ), Applicability::Unspecified, ); ...
{ let mut triggered = false; if let (ty::Ref(_, ty_from, from_mutbl), ty::Ref(_, ty_to, to_mutbl)) = (&from_ty.kind(), &to_ty.kind()) { if_chain! { if let (&ty::Slice(slice_ty), &ty::Str) = (&ty_from.kind(), &ty_to.kind()); if let ty::Uint(ty::UintTy::U8) = slice_ty.kind(); ...
identifier_body
transmute_ref_to_ref.rs
use super::{TRANSMUTE_BYTES_TO_STR, TRANSMUTE_PTR_TO_PTR}; use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_and_then}; use clippy_utils::source::snippet; use clippy_utils::sugg; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::{Expr, Mutability}; use rustc_lint::LateContext; use rust...
postfix, snippet(cx, args[0].span, ".."), ), Applicability::Unspecified, ); triggered = true; } else { if (cx.tcx.erase_regions(from_ty)!= cx.tcx.erase_regions(to_ty)) ...
{ if_chain! { if let (&ty::Slice(slice_ty), &ty::Str) = (&ty_from.kind(), &ty_to.kind()); if let ty::Uint(ty::UintTy::U8) = slice_ty.kind(); if from_mutbl == to_mutbl; then { let postfix = if *from_mutbl == Mutability::Mut { "_m...
conditional_block
transmute_ref_to_ref.rs
use super::{TRANSMUTE_BYTES_TO_STR, TRANSMUTE_PTR_TO_PTR}; use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_and_then}; use clippy_utils::source::snippet; use clippy_utils::sugg; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::{Expr, Mutability}; use rustc_lint::LateContext; use rust...
<'tcx>( cx: &LateContext<'tcx>, e: &'tcx Expr<'_>, from_ty: Ty<'tcx>, to_ty: Ty<'tcx>, args: &'tcx [Expr<'_>], const_context: bool, ) -> bool { let mut triggered = false; if let (ty::Ref(_, ty_from, from_mutbl), ty::Ref(_, ty_to, to_mutbl)) = (&from_ty.kind(), &to_ty.kind()) { i...
check
identifier_name
transmute_ref_to_ref.rs
use super::{TRANSMUTE_BYTES_TO_STR, TRANSMUTE_PTR_TO_PTR}; use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_and_then}; use clippy_utils::source::snippet; use clippy_utils::sugg; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::{Expr, Mutability}; use rustc_lint::LateContext; use rust...
if let (&ty::Slice(slice_ty), &ty::Str) = (&ty_from.kind(), &ty_to.kind()); if let ty::Uint(ty::UintTy::U8) = slice_ty.kind(); if from_mutbl == to_mutbl; then { let postfix = if *from_mutbl == Mutability::Mut { "_mut" } ...
let mut triggered = false; if let (ty::Ref(_, ty_from, from_mutbl), ty::Ref(_, ty_to, to_mutbl)) = (&from_ty.kind(), &to_ty.kind()) { if_chain! {
random_line_split
login.rs
// Copyright 2016 Matthew Collins // // 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...
self.vars.set(auth::CL_USERNAME, val.username.clone()); self.vars.set(auth::CL_UUID, val.id.clone()); self.vars.set(auth::AUTH_TOKEN, val.access_token.clone()); elements.profile = val; return Some(Box...
random_line_split
login.rs
// Copyright 2016 Matthew Collins // // 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...
let client_token = self.vars.get(auth::AUTH_CLIENT_TOKEN).clone(); let username = elements.username_txt.borrow().input.clone(); let password = elements.password_txt.borrow().input.clone(); let refresh = elements.refresh; let profile = elements.profile.clone()...
{ client_token = rand::thread_rng().gen_ascii_chars().take(20).collect::<String>(); self.vars.set(auth::AUTH_CLIENT_TOKEN, client_token); }
conditional_block
login.rs
// Copyright 2016 Matthew Collins // // 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...
(&mut self, renderer: &mut render::Renderer, ui_container: &mut ui::Container) { let logo = ui::logo::Logo::new(renderer.resources.clone(), ui_container); let try_login = Rc::new(Cell::new(false)); // Login let login_btn = ui::ButtonBuilder::new() .position(0.0, 100.0) ...
on_active
identifier_name
sepcomp-cci.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 ...
() { assert_eq!(call1(), 1234); assert_eq!(a::call2(), 1234); assert_eq!(b::call3(), 1234); }
main
identifier_name
sepcomp-cci.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 main() { assert_eq!(call1(), 1234); assert_eq!(a::call2(), 1234); assert_eq!(b::call3(), 1234); }
{ cci_fn() + CCI_STATIC }
identifier_body
sepcomp-cci.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 accessing cross-crate inlined items from multiple compilation units. // pretty-expanded FIXME #23616 extern crate sepcomp_cci_lib; use sepcomp_cci_lib::{cci_fn, CCI_STATIC}; fn call1() -> usize { cci_fn() + CCI_STATIC } mod a { use sepcomp_cci_lib::{cci_fn, CCI_STATIC}; pub fn call2() -> usize ...
// except according to those terms. // compile-flags: -C codegen-units=3 // aux-build:sepcomp_cci_lib.rs
random_line_split
util.rs
// // imag - the personal information management suite for the commandline // Copyright (C) 2015-2020 Matthias Beyer <mail@beyermatthias.de> and contributors // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the F...
scmd.value_of("format") .map(String::from) .map(Ok) .unwrap_or_else(|| { rt.config() .ok_or_else(|| anyhow!("No configuration file"))? .read_string(config_value_path)? .ok_or_else(|| anyhow!("Configuration 'contact.list_format' does not e...
-> Result<Handlebars<'rc>> {
random_line_split
util.rs
// // imag - the personal information management suite for the commandline // Copyright (C) 2015-2020 Matthias Beyer <mail@beyermatthias.de> and contributors // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the F...
<'a> { inner: FileLockEntry<'a>, data: ICalendar, } impl<'a> ParsedEventFLE<'a> { /// Because libimagcalendar only links to the actual calendar data, we need to read the data and /// parse it. /// With this function, a FileLockEntry can be parsed to a ParsedEventFileLockEntry /// (ParsedEventF...
ParsedEventFLE
identifier_name
util.rs
// // imag - the personal information management suite for the commandline // Copyright (C) 2015-2020 Matthias Beyer <mail@beyermatthias.de> and contributors // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the F...
let take = event .as_ref() .map(|e| { trace!("Checking whether {:?} starts with {}", e.uid(), id); e.uid().map(|uid| uid.raw().starts_with(id)).unwrap_or(false) }) .unwrap_or(fals...
{ if let Some(entry) = store.get_event_by_uid(id)? { debug!("Found directly: {} -> {}", id, entry.get_location()); return ParsedEventFLE::parse(entry, refconfig).map(Some) } for sid in store.all_events()? { let sid = sid?; let event = store.get(sid.clone())?.ok_or_else(|| {...
identifier_body
util.rs
// // imag - the personal information management suite for the commandline // Copyright (C) 2015-2020 Matthias Beyer <mail@beyermatthias.de> and contributors // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the F...
for sid in store.all_events()? { let sid = sid?; let event = store.get(sid.clone())?.ok_or_else(|| { anyhow!("Cannot get {}, which should be there.", sid) })?; trace!("Checking whether {} is represented by {}", id, event.get_location()); let parsed = ParsedEve...
{ debug!("Found directly: {} -> {}", id, entry.get_location()); return ParsedEventFLE::parse(entry, refconfig).map(Some) }
conditional_block
add.rs
#![feature(core, core_simd)] extern crate core; #[cfg(test)] mod tests { use core::simd::u32x4; // #[simd] // #[derive(Copy, Clone, Debug)] // #[repr(C)] // pub struct u32x4(pub u32, pub u32, pub u32, pub u32); #[test] fn
() { let x: u32x4 = u32x4( 0, 1, 2, 3 ); let y: u32x4 = u32x4( 2, 2, 2, 2 ); let z: u32x4 = x + y; let result: String = format!("{:?}", z); assert_eq!(result, "u32x4(2, 3, 4, 5)".to_string()); } }
add_test1
identifier_name
add.rs
#![feature(core, core_simd)] extern crate core; #[cfg(test)] mod tests { use core::simd::u32x4; // #[simd] // #[derive(Copy, Clone, Debug)] // #[repr(C)] // pub struct u32x4(pub u32, pub u32, pub u32, pub u32); #[test] fn add_test1()
}
{ let x: u32x4 = u32x4( 0, 1, 2, 3 ); let y: u32x4 = u32x4( 2, 2, 2, 2 ); let z: u32x4 = x + y; let result: String = format!("{:?}", z); assert_eq!(result, "u32x4(2, 3, 4, 5)".to_string()); }
identifier_body
add.rs
#![feature(core, core_simd)] extern crate core; #[cfg(test)] mod tests { use core::simd::u32x4; // #[simd] // #[derive(Copy, Clone, Debug)] // #[repr(C)] // pub struct u32x4(pub u32, pub u32, pub u32, pub u32); #[test] fn add_test1() { let x: u32x4 = u32x4( 0, 1, 2, 3 ); let y...
let result: String = format!("{:?}", z); assert_eq!(result, "u32x4(2, 3, 4, 5)".to_string()); } }
); let z: u32x4 = x + y;
random_line_split
watcher.rs
// Copyright (C) 2013 - 2021 Tim Düsterhus // Copyright (C) 2021 Maximilian Mader // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your opt...
}; Ok(watcher) } fn start_scan(&self) { let maybe_locked = self.scanning.try_lock(); if maybe_locked.is_err() { // A scan is already running return; } let scanning = Arc::clone(&self.scanning); std::thread::spawn(move || { ...
inner, path, scanning: Arc::new(Mutex::new(())),
random_line_split
watcher.rs
// Copyright (C) 2013 - 2021 Tim Düsterhus // Copyright (C) 2021 Maximilian Mader // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your opt...
path: &'a Path, tx: Sender<DebouncedEvent>) -> notify::Result<Self> { let mut inner = notify::watcher(tx, std::time::Duration::from_secs(5))?; inner.watch(&path, RecursiveMode::Recursive)?; let watcher = Self { inner, path, scanning: Arc::new(Mutex::new(()))...
ew(
identifier_name
watcher.rs
// Copyright (C) 2013 - 2021 Tim Düsterhus // Copyright (C) 2021 Maximilian Mader // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your opt...
} impl std::fmt::Debug for PackageWatcher<'_> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct("PackageWatcher") .field("path", &self.path) .finish() } } impl Drop for PackageWatcher<'_> { fn drop(&mut self) { self.inner.unwatch(&s...
loop { match rx.recv() { Ok(DebouncedEvent::Error(err, Some(path))) => { log::error!("Watch error in path {:?}: {:?}", path, err); } Ok(DebouncedEvent::Error(err, None)) => { log::error!("Watch error: {:?}", err...
identifier_body
constellation_msg.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/. */ //! The high-level interface from script to constellation. Using this abstract interface helps //! reduce coupling...
impl PipelineNamespace { pub fn install(namespace_id: PipelineNamespaceId) { PIPELINE_NAMESPACE.with(|tls| { assert!(tls.get().is_none()); tls.set(Some(PipelineNamespace { id: namespace_id, index: 0, })); }); } fn next_inde...
id: PipelineNamespaceId, index: u32, }
random_line_split
constellation_msg.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/. */ //! The high-level interface from script to constellation. Using this abstract interface helps //! reduce coupling...
(namespace_id: PipelineNamespaceId) { PIPELINE_NAMESPACE.with(|tls| { assert!(tls.get().is_none()); tls.set(Some(PipelineNamespace { id: namespace_id, index: 0, })); }); } fn next_index(&mut self) -> u32 { let result = ...
install
identifier_name
generic-cast.rs
// build-fail #![feature(repr_simd, platform_intrinsics)] #[repr(simd)] #[derive(Copy, Clone)] #[allow(non_camel_case_types)] struct i32x4(i32, i32, i32, i32); #[repr(simd)] #[derive(Copy, Clone)] #[allow(non_camel_case_types)] struct i32x8(i32, i32, i32, i32, i32, i32, i32, i32); #[repr(simd)] #[derive...
extern "platform-intrinsic" { fn simd_cast<T, U>(x: T) -> U; } fn main() { let x = i32x4(0, 0, 0, 0); unsafe { simd_cast::<i32, i32>(0); //~^ ERROR expected SIMD input type, found non-SIMD `i32` simd_cast::<i32, i32x4>(0); //~^ ERROR expected SIMD input type, found non-SIMD...
random_line_split
generic-cast.rs
// build-fail #![feature(repr_simd, platform_intrinsics)] #[repr(simd)] #[derive(Copy, Clone)] #[allow(non_camel_case_types)] struct i32x4(i32, i32, i32, i32); #[repr(simd)] #[derive(Copy, Clone)] #[allow(non_camel_case_types)] struct i32x8(i32, i32, i32, i32, i32, i32, i32, i32); #[repr(simd)] #[derive...
() { let x = i32x4(0, 0, 0, 0); unsafe { simd_cast::<i32, i32>(0); //~^ ERROR expected SIMD input type, found non-SIMD `i32` simd_cast::<i32, i32x4>(0); //~^ ERROR expected SIMD input type, found non-SIMD `i32` simd_cast::<i32x4, i32>(x); //~^ ERROR expected SIMD...
main
identifier_name
mod.rs
pub mod io; use io::{BitInputStream, BitOutputStream}; pub const MAX_SYMBOLS: usize = 256; #[derive(Clone)] enum Tree { Leaf(usize, u8), Node(usize, Box<Tree>, Box<Tree>) } fn freq_tree(t:&Tree) -> usize { match *t { Tree::Leaf(f, _) => f, Tree::Node(f, _, _)=> f } } fn freq(t:&Option<Tree>) -> usize { ma...
} min } } pub fn size(&mut self) -> usize { self.last } } pub struct HuffTree { tree: Tree, codes: Vec<String> } impl HuffTree { pub fn build(mut reader: &mut BitInputStream) -> HuffTree { let freqs :[usize; MAX_SYMBOLS] = HuffTree::calc_frecuencies(&mut reader); let mut heap = Heap::new(MAX_SYM...
j = k;
random_line_split
mod.rs
pub mod io; use io::{BitInputStream, BitOutputStream}; pub const MAX_SYMBOLS: usize = 256; #[derive(Clone)] enum Tree { Leaf(usize, u8), Node(usize, Box<Tree>, Box<Tree>) } fn freq_tree(t:&Tree) -> usize { match *t { Tree::Leaf(f, _) => f, Tree::Node(f, _, _)=> f } } fn freq(t:&Option<Tree>) -> usize { ma...
fn read_char(tree: &Tree, reader: &mut BitInputStream) -> u8 { match *tree { Tree::Leaf(_, sym) => { sym } Tree::Node(_, ref left, ref right) => { if reader.read_bool() { read_char(right, reader) } else { read_char(left, reader) } } } } struct Heap { data: Vec<Option<Tree>>, last: usi...
{ match *tree { Tree::Leaf(_, sym) => { writer.write_bit(1); writer.write_byte(u16::from(sym)); } Tree::Node(_, ref left, ref right) => { writer.write_bit(0); write_tree(left, writer); write_tree(right, writer); } } }
identifier_body
mod.rs
pub mod io; use io::{BitInputStream, BitOutputStream}; pub const MAX_SYMBOLS: usize = 256; #[derive(Clone)] enum Tree { Leaf(usize, u8), Node(usize, Box<Tree>, Box<Tree>) } fn freq_tree(t:&Tree) -> usize { match *t { Tree::Leaf(f, _) => f, Tree::Node(f, _, _)=> f } } fn freq(t:&Option<Tree>) -> usize { ma...
Tree::Node(_, ref left, ref right) => { if reader.read_bool() { read_char(right, reader) } else { read_char(left, reader) } } } } struct Heap { data: Vec<Option<Tree>>, last: usize } impl Heap { pub fn new(size:usize) -> Heap { Heap { data : vec![None;size+1], last : 0 } } pub ...
{ sym }
conditional_block
mod.rs
pub mod io; use io::{BitInputStream, BitOutputStream}; pub const MAX_SYMBOLS: usize = 256; #[derive(Clone)] enum Tree { Leaf(usize, u8), Node(usize, Box<Tree>, Box<Tree>) } fn freq_tree(t:&Tree) -> usize { match *t { Tree::Leaf(f, _) => f, Tree::Node(f, _, _)=> f } } fn freq(t:&Option<Tree>) -> usize { ma...
{ tree: Tree, codes: Vec<String> } impl HuffTree { pub fn build(mut reader: &mut BitInputStream) -> HuffTree { let freqs :[usize; MAX_SYMBOLS] = HuffTree::calc_frecuencies(&mut reader); let mut heap = Heap::new(MAX_SYMBOLS); for (s, &f) in freqs.iter().enumerate() { if f > 0 { heap.insert(Tree::Leaf(...
HuffTree
identifier_name
overloaded-index-assoc-list.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
let mut list = AssociationList {pairs: Vec::new()}; list.push(foo.clone(), 22); list.push(bar.clone(), 44); assert_eq!(list[&foo], 22); assert_eq!(list[&bar], 44); assert_eq!(list[&foo], 22); assert_eq!(list[&bar], 44); }
let foo = "foo".to_string(); let bar = "bar".to_string();
random_line_split
overloaded-index-assoc-list.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 ...
} panic!("No value found for key: {:?}", index); } } pub fn main() { let foo = "foo".to_string(); let bar = "bar".to_string(); let mut list = AssociationList {pairs: Vec::new()}; list.push(foo.clone(), 22); list.push(bar.clone(), 44); assert_eq!(list[&foo], 22); asser...
{ return &pair.value }
conditional_block
overloaded-index-assoc-list.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { let foo = "foo".to_string(); let bar = "bar".to_string(); let mut list = AssociationList {pairs: Vec::new()}; list.push(foo.clone(), 22); list.push(bar.clone(), 44); assert_eq!(list[&foo], 22); assert_eq!(list[&bar], 44); assert_eq!(list[&foo], 22); assert_eq!(list[&bar], 44)...
main
identifier_name
feature.rs
use lv2::core::*; #[derive(PartialEq, Eq, Debug, Copy, Clone)] struct MyFeature(u8); unsafe impl Feature for MyFeature { const URI: &'static [u8] = b"http://proko.eu/my_feature\0"; } #[derive(Copy, Clone)] struct MyVecFeature<'a>(pub &'a Vec<u8>); unsafe impl<'a> Feature for MyVecFeature<'a> { const URI: &'...
#[test] fn lifetime_feature() { let buf = vec![42, 69]; let f = MyVecFeature(&buf); let desc: FeatureDescriptor = (&f).into(); let fo: &MyVecFeature = desc.as_feature().unwrap(); assert_eq!(fo.0, &vec![42u8, 69]) } #[test] fn feature_buffer() { let vec = vec![42, 69]; let feature = MyFea...
{ let f = MyFeature(42); let desc: FeatureDescriptor = (&f).into(); assert_eq!(desc.as_feature::<MyFeature>().unwrap(), &MyFeature(42)) }
identifier_body
feature.rs
use lv2::core::*; #[derive(PartialEq, Eq, Debug, Copy, Clone)] struct MyFeature(u8); unsafe impl Feature for MyFeature { const URI: &'static [u8] = b"http://proko.eu/my_feature\0"; } #[derive(Copy, Clone)] struct MyVecFeature<'a>(pub &'a Vec<u8>); unsafe impl<'a> Feature for MyVecFeature<'a> { const URI: &'...
fn to_list(&'a self) -> FeatureBuffer<'a> { let mut vec = Vec::with_capacity(2); if let Some(feature) = &self.my_feature { vec.push(Feature::descriptor(feature)) } if let Some(feature) = &self.my_vec_feature { vec.push(Feature::descriptor(feature)) } FeatureBuffer::from_vec(vec) ...
random_line_split
feature.rs
use lv2::core::*; #[derive(PartialEq, Eq, Debug, Copy, Clone)] struct MyFeature(u8); unsafe impl Feature for MyFeature { const URI: &'static [u8] = b"http://proko.eu/my_feature\0"; } #[derive(Copy, Clone)] struct MyVecFeature<'a>(pub &'a Vec<u8>); unsafe impl<'a> Feature for MyVecFeature<'a> { const URI: &'...
() { let buf = vec![42, 69]; let f = MyVecFeature(&buf); let desc: FeatureDescriptor = (&f).into(); let fo: &MyVecFeature = desc.as_feature().unwrap(); assert_eq!(fo.0, &vec![42u8, 69]) } #[test] fn feature_buffer() { let vec = vec![42, 69]; let feature = MyFeature(21); let feature_vec...
lifetime_feature
identifier_name
progressevent.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::EventBinding::EventMethods; use dom::bindings::codegen::Bindings::ProgressEv...
} impl ProgressEvent { fn new_inherited(length_computable: bool, loaded: u64, total: u64) -> ProgressEvent { ProgressEvent { event: Event::new_inherited(EventTypeId::ProgressEvent), length_computable: length_computable, loaded: loaded, total: total } ...
random_line_split
progressevent.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::EventBinding::EventMethods; use dom::bindings::codegen::Bindings::ProgressEv...
fn Loaded(self) -> u64{ self.loaded } fn Total(self) -> u64 { self.total } }
{ self.length_computable }
identifier_body
progressevent.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::EventBinding::EventMethods; use dom::bindings::codegen::Bindings::ProgressEv...
(self) -> bool { self.length_computable } fn Loaded(self) -> u64{ self.loaded } fn Total(self) -> u64 { self.total } }
LengthComputable
identifier_name
debug.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. */ //! edenfsctl config use async_trait::async_trait; use clap::Parser; use edenfs_client::EdenFsInstance; use edenfs_error::Result; use cr...
(&self, instance: EdenFsInstance) -> Result<ExitCode> { use DebugSubcommand::*; let sc: &(dyn Subcommand + Send + Sync) = match &self.subcommand { ClearLocalCaches(cmd) => cmd, CompactLocalStorage(cmd) => cmd, }; sc.run(instance).await } }
run
identifier_name
debug.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. */ //! edenfsctl config use async_trait::async_trait; use clap::Parser; use edenfs_client::EdenFsInstance; use edenfs_error::Result; use cr...
pub enum DebugSubcommand { ClearLocalCaches(clear_local_caches::ClearLocalCachesCmd), CompactLocalStorage(compact_local_storage::CompactLocalStorageCmd), } #[async_trait] impl Subcommand for DebugCmd { async fn run(&self, instance: EdenFsInstance) -> Result<ExitCode> { use DebugSubcommand::*; ...
random_line_split
result.rs
use std::{ convert::Infallible, iter::FromIterator, ops::{ControlFlow, FromResidual, Try}, }; use super::value::Value; #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum DiscoverResult<T = Value> { Value(T), Panic(Value), DependsOnParameter, ErrorInHir, } impl<T> Try for DiscoverResult<...
type Output = T; type Residual = DiscoverResult<Infallible>; fn from_output(output: Self::Output) -> Self { DiscoverResult::Value(output) } fn branch(self) -> std::ops::ControlFlow<Self::Residual, Self::Output> { match self { DiscoverResult::Value(value) => ControlFlow::...
random_line_split
result.rs
use std::{ convert::Infallible, iter::FromIterator, ops::{ControlFlow, FromResidual, Try}, }; use super::value::Value; #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum DiscoverResult<T = Value> { Value(T), Panic(Value), DependsOnParameter, ErrorInHir, } impl<T> Try for DiscoverResult<...
} impl<T> FromResidual for DiscoverResult<T> { fn from_residual(residual: DiscoverResult<Infallible>) -> Self { match residual { DiscoverResult::Value(_) => unreachable!(), DiscoverResult::Panic(panic) => DiscoverResult::Panic(panic), DiscoverResult::DependsOnParameter =...
{ match self { DiscoverResult::Value(value) => ControlFlow::Continue(value), DiscoverResult::Panic(panic) => ControlFlow::Break(DiscoverResult::Panic(panic)), DiscoverResult::DependsOnParameter => { ControlFlow::Break(DiscoverResult::DependsOnParameter) ...
identifier_body
result.rs
use std::{ convert::Infallible, iter::FromIterator, ops::{ControlFlow, FromResidual, Try}, }; use super::value::Value; #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum DiscoverResult<T = Value> { Value(T), Panic(Value), DependsOnParameter, ErrorInHir, } impl<T> Try for DiscoverResult<...
(residual: DiscoverResult<Infallible>) -> Self { match residual { DiscoverResult::Value(_) => unreachable!(), DiscoverResult::Panic(panic) => DiscoverResult::Panic(panic), DiscoverResult::DependsOnParameter => DiscoverResult::DependsOnParameter, DiscoverResult::Er...
from_residual
identifier_name
overloaded-index.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 ...
(&mut self) { *self += 1; } } fn main() { let mut f = Foo { x: 1, y: 2, }; assert_eq!(f[1], 2); f[0] = 3; assert_eq!(f[0], 3); { let p = &mut f[1]; *p = 4; } { let p = &f[1]; assert_eq!(*p, 4); } // Test calling methods with `&mut...
inc
identifier_name
overloaded-index.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 ...
} } trait Int { fn get(self) -> isize; fn get_from_ref(&self) -> isize; fn inc(&mut self); } impl Int for isize { fn get(self) -> isize { self } fn get_from_ref(&self) -> isize { *self } fn inc(&mut self) { *self += 1; } } fn main() { let mut f = Foo { x: 1, y: 2, ...
{ &mut self.y }
conditional_block
overloaded-index.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 ...
} trait Int { fn get(self) -> isize; fn get_from_ref(&self) -> isize; fn inc(&mut self); } impl Int for isize { fn get(self) -> isize { self } fn get_from_ref(&self) -> isize { *self } fn inc(&mut self) { *self += 1; } } fn main() { let mut f = Foo { x: 1, y: 2, }; ...
{ if z == 0 { &mut self.x } else { &mut self.y } }
identifier_body
overloaded-index.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!(f[1].get_from_ref(), 5); }
random_line_split
prefs.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::basedir::default_config_dir; use crate::opts; use embedder_traits::resources::{self, Resource}; use se...
pub enum PrefValue { Boolean(bool), String(String), Number(f64), Missing, } impl PrefValue { pub fn from_json(data: Value) -> Result<PrefValue, ()> { let value = match data { Value::Bool(x) => PrefValue::Boolean(x), Value::String(x) => PrefValue::String(x), ...
} #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
random_line_split
prefs.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::basedir::default_config_dir; use crate::opts; use embedder_traits::resources::{self, Resource}; use se...
(&self, name: &str) -> Arc<PrefValue> { let mut prefs = self.0.write().unwrap(); let result = match prefs.get_mut(name) { None => return Arc::new(PrefValue::Missing), Some(&mut Pref::NoDefault(_)) => Arc::new(PrefValue::Missing), Some(&mut Pref::WithDefault(ref defaul...
reset
identifier_name
prefs.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::basedir::default_config_dir; use crate::opts; use embedder_traits::resources::{self, Resource}; use se...
pub fn as_boolean(&self) -> Option<bool> { match *self { PrefValue::Boolean(value) => Some(value), _ => None, } } pub fn as_string(&self) -> Option<&str> { match *self { PrefValue::String(ref value) => Some(&value), _ => None, ...
{ let value = match data { Value::Bool(x) => PrefValue::Boolean(x), Value::String(x) => PrefValue::String(x), Value::Number(x) => { if let Some(v) = x.as_f64() { PrefValue::Number(v) } else { return Err((...
identifier_body
unboxed-closures-manual-impl.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 ...
<F:FnMut(i32)->i32>(mut f: F, x: i32) -> i32 { f(x) + 3 } fn call_box(f: &mut FnMut(i32) -> i32, x: i32) -> i32 { f(x) + 3 } fn main() { let x = call_it(S, 1); let y = call_box(&mut S, 1); assert_eq!(x, 4); assert_eq!(y, 4); }
call_it
identifier_name
unboxed-closures-manual-impl.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
// option. This file may not be copied, modified, or distributed // except according to those terms. // run-pass #![feature(unboxed_closures, fn_traits)] struct S; impl FnMut<(i32,)> for S { extern "rust-call" fn call_mut(&mut self, (x,): (i32,)) -> i32 { x * x } } impl FnOnce<(i32,)> for S { ty...
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
random_line_split
unboxed-closures-manual-impl.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn main() { let x = call_it(S, 1); let y = call_box(&mut S, 1); assert_eq!(x, 4); assert_eq!(y, 4); }
{ f(x) + 3 }
identifier_body
gump_scene.rs
use cgmath::Point2; use ggez::event::{KeyCode, KeyMods}; use ggez::graphics::{self, Canvas, DrawParam, Text}; use ggez::{Context, GameResult}; use image_convert::image_to_surface; use scene::{BoxedScene, Scene, SceneChangeEvent, SceneName}; use std::fs::File; use std::io::Result; use std::path::Path; use uorustlibs::gu...
pub struct GumpScene { reader: Result<GumpReader<File>>, index: u32, texture: Option<Canvas>, exiting: bool, } impl<'a> GumpScene { pub fn new(ctx: &mut Context) -> BoxedScene<'a, SceneName, ()> { let reader = GumpReader::new( &Path::new("./assets/gumpidx.mul"), &Pa...
random_line_split
gump_scene.rs
use cgmath::Point2; use ggez::event::{KeyCode, KeyMods}; use ggez::graphics::{self, Canvas, DrawParam, Text}; use ggez::{Context, GameResult}; use image_convert::image_to_surface; use scene::{BoxedScene, Scene, SceneChangeEvent, SceneName}; use std::fs::File; use std::io::Result; use std::path::Path; use uorustlibs::gu...
fn update( &mut self, _ctx: &mut Context, _engine_data: &mut (), ) -> GameResult<Option<SceneChangeEvent<SceneName>>> { if self.exiting { Ok(Some(SceneChangeEvent::PopScene)) } else { Ok(None) } } fn key_down_event( &mut ...
{ match self.texture { Some(ref texture) => { graphics::draw(ctx, texture, DrawParam::default())?; } None => (), }; Ok(()) }
identifier_body
gump_scene.rs
use cgmath::Point2; use ggez::event::{KeyCode, KeyMods}; use ggez::graphics::{self, Canvas, DrawParam, Text}; use ggez::{Context, GameResult}; use image_convert::image_to_surface; use scene::{BoxedScene, Scene, SceneChangeEvent, SceneName}; use std::fs::File; use std::io::Result; use std::path::Path; use uorustlibs::gu...
(&mut self, ctx: &mut Context, _engine_data: &mut ()) -> GameResult<()> { match self.texture { Some(ref texture) => { graphics::draw(ctx, texture, DrawParam::default())?; } None => (), }; Ok(()) } fn update( &mut self, ...
draw
identifier_name
gump_scene.rs
use cgmath::Point2; use ggez::event::{KeyCode, KeyMods}; use ggez::graphics::{self, Canvas, DrawParam, Text}; use ggez::{Context, GameResult}; use image_convert::image_to_surface; use scene::{BoxedScene, Scene, SceneChangeEvent, SceneName}; use std::fs::File; use std::io::Result; use std::path::Path; use uorustlibs::gu...
} } } _ => {} } } fn cycle_forward(&mut self) { match self.reader { Ok(ref mut reader) => loop { self.index += 1; match reader.read_gump(self.index) { Ok(_) => { ...
{}
conditional_block
mod.rs
mod macaddr; pub use self::macaddr::*; packet!(EthernetPacket, MutEthernetPacket, 14); getters!(EthernetPacket pub fn destination(&self) -> MacAddr { MacAddr::from_slice(&self.0[0..6]) } pub fn source(&self) -> MacAddr { MacAddr::from_slice(&self.0[6..12]) } pub fn ether_type(&se...
(pub u16); impl EtherType { pub const IPV4: EtherType = EtherType(0x0800); pub const ARP: EtherType = EtherType(0x0806); pub const IPV6: EtherType = EtherType(0x86DD); #[inline] pub fn value(&self) -> u16 { self.0 } } #[cfg(test)] mod tests { use super::*; static MAC: [u8; 6...
EtherType
identifier_name
mod.rs
mod macaddr; pub use self::macaddr::*; packet!(EthernetPacket, MutEthernetPacket, 14); getters!(EthernetPacket pub fn destination(&self) -> MacAddr { MacAddr::from_slice(&self.0[0..6]) } pub fn source(&self) -> MacAddr { MacAddr::from_slice(&self.0[6..12]) } pub fn ether_type(&se...
} #[cfg(test)] mod tests { use super::*; static MAC: [u8; 6] = [0xff; 6]; macro_rules! eth_setget_test { ($name:ident, $set_name:ident, $value:expr, $offset:expr, $expected:expr) => { setget_test!(MutEthernetPacket, $name, $set_name, $value, $offset, $expected); } } ...
{ self.0 }
identifier_body
mod.rs
mod macaddr; pub use self::macaddr::*; packet!(EthernetPacket, MutEthernetPacket, 14); getters!(EthernetPacket pub fn destination(&self) -> MacAddr { MacAddr::from_slice(&self.0[0..6]) } pub fn source(&self) -> MacAddr { MacAddr::from_slice(&self.0[6..12]) } pub fn ether_type(&se...
/// /// [IANA's website]: https://www.iana.org/assignments/ieee-802-numbers/ieee-802-numbers.xhtml #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] pub struct EtherType(pub u16); impl EtherType { pub const IPV4: EtherType = EtherType(0x0800); pub const ARP: EtherType = EtherType(0x0806); pub const IPV6: ...
/// A few select, commonly used, values are attached as associated constants. Their values are /// defined on [IANA's website].
random_line_split
browsercontext.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::js::{JS, JSRef, Temporary}; use dom::bindings::trace::Traceable; use dom::bindings::utils::Refl...
#[deriving(Encodable)] pub struct SessionHistoryEntry { document: JS<Document>, children: Vec<BrowserContext> } impl SessionHistoryEntry { fn new(document: &JSRef<Document>) -> SessionHistoryEntry { SessionHistoryEntry { document: JS::from_rooted(document), children: vec!()...
} }
random_line_split
browsercontext.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::js::{JS, JSRef, Temporary}; use dom::bindings::trace::Traceable; use dom::bindings::utils::Refl...
(document: &JSRef<Document>) -> SessionHistoryEntry { SessionHistoryEntry { document: JS::from_rooted(document), children: vec!() } } } static proxy_handler: ProxyTraps = ProxyTraps { getPropertyDescriptor: None, getOwnPropertyDescriptor: None, defineProperty: No...
new
identifier_name
browsercontext.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::js::{JS, JSRef, Temporary}; use dom::bindings::trace::Traceable; use dom::bindings::utils::Refl...
pub fn window_proxy(&self) -> *mut JSObject { assert!(self.window_proxy.deref().is_not_null()); *self.window_proxy } fn create_window_proxy(&mut self) { let win = self.active_window().root(); let page = win.deref().page(); let js_info = page.js_info(); let...
{ let doc = self.active_document().root(); Temporary::new(doc.deref().window.clone()) }
identifier_body
script.rs
use sha1::Sha1; use cmd::cmd; use types::{ToRedisArgs, FromRedisValue, RedisResult, ErrorKind}; use connection::ConnectionLike; /// Represents a lua script. pub struct Script { code: String, hash: String, } /// The script object represents a lua script that can be executed on the /// redis server. The objec...
} } } }
} else { fail!(err); } }
random_line_split
script.rs
use sha1::Sha1; use cmd::cmd; use types::{ToRedisArgs, FromRedisValue, RedisResult, ErrorKind}; use connection::ConnectionLike; /// Represents a lua script. pub struct Script { code: String, hash: String, } /// The script object represents a lua script that can be executed on the /// redis server. The objec...
/// Returns the script's SHA1 hash in hexadecimal format. pub fn get_hash(&self) -> &str { &self.hash } /// Creates a script invocation object with a key filled in. #[inline] pub fn key<T: ToRedisArgs>(&self, key: T) -> ScriptInvocation { ScriptInvocation { script:...
{ let mut hash = Sha1::new(); hash.update(code.as_bytes()); Script { code: code.to_string(), hash: hash.hexdigest(), } }
identifier_body
script.rs
use sha1::Sha1; use cmd::cmd; use types::{ToRedisArgs, FromRedisValue, RedisResult, ErrorKind}; use connection::ConnectionLike; /// Represents a lua script. pub struct Script { code: String, hash: String, } /// The script object represents a lua script that can be executed on the /// redis server. The objec...
<T: FromRedisValue>(&self, con: &ConnectionLike) -> RedisResult<T> { loop { match cmd("EVALSHA") .arg(self.script.hash.as_bytes()) .arg(self.keys.len()) .arg(&*self.keys) .arg(&*self.args).query(con) { Ok(val) => { return Ok...
invoke
identifier_name
script.rs
use sha1::Sha1; use cmd::cmd; use types::{ToRedisArgs, FromRedisValue, RedisResult, ErrorKind}; use connection::ConnectionLike; /// Represents a lua script. pub struct Script { code: String, hash: String, } /// The script object represents a lua script that can be executed on the /// redis server. The objec...
else { fail!(err); } } } } } }
{ let _ : () = try!(cmd("SCRIPT") .arg("LOAD") .arg(self.script.code.as_bytes()) .query(con)); }
conditional_block
day04.rs
use std::fs::File; use std::io::prelude::*; use std::io::BufReader; use std::collections::BTreeMap; pub fn obsecurity_1(file: &str) -> usize { let (sum, _) = parse_rooms(file); sum } pub fn obsecurity_2(file: &str, room_search_term: &str) -> usize { let (_, rooms) = parse_rooms(file); let mut names = ...
encrypted: words.iter().map(|s| s.to_string()).collect::<Vec<String>>(), }); sum += id; } } } }; // println!(""); } (sum, rooms) } struct Room { encrypted: Vec<String>...
if checksum == checkedsum { // Collect verified rooms rooms.push(Room { id: id,
random_line_split
day04.rs
use std::fs::File; use std::io::prelude::*; use std::io::BufReader; use std::collections::BTreeMap; pub fn obsecurity_1(file: &str) -> usize { let (sum, _) = parse_rooms(file); sum } pub fn obsecurity_2(file: &str, room_search_term: &str) -> usize { let (_, rooms) = parse_rooms(file); let mut names = ...
(file: &str) -> (usize, Vec<Room>) { let input = File::open(file).expect("File open fail."); let reader = BufReader::new(input); let lines: Vec<String> = reader.lines() .filter_map(Result::ok) .collect(); let mut rooms = Vec::new(); let mut sum = 0; for line in lines { le...
parse_rooms
identifier_name
day04.rs
use std::fs::File; use std::io::prelude::*; use std::io::BufReader; use std::collections::BTreeMap; pub fn obsecurity_1(file: &str) -> usize { let (sum, _) = parse_rooms(file); sum } pub fn obsecurity_2(file: &str, room_search_term: &str) -> usize { let (_, rooms) = parse_rooms(file); let mut names = ...
names.push(name); } println!("{:?}", names); 42 } fn parse_rooms(file: &str) -> (usize, Vec<Room>) { let input = File::open(file).expect("File open fail."); let reader = BufReader::new(input); let lines: Vec<String> = reader.lines() .filter_map(Result::ok) .collect(); ...
{ return room.id; }
conditional_block
day04.rs
use std::fs::File; use std::io::prelude::*; use std::io::BufReader; use std::collections::BTreeMap; pub fn obsecurity_1(file: &str) -> usize { let (sum, _) = parse_rooms(file); sum } pub fn obsecurity_2(file: &str, room_search_term: &str) -> usize { let (_, rooms) = parse_rooms(file); let mut names = ...
// println!("{}", id); // println!("{:?}", checksum); let letters = words.iter().flat_map(|s| s.chars()).collect::<Vec<char>>(); // println!("{:?}", letters); let mut counts = BTreeMap::new(); for c in letters.iter() { ...
{ let input = File::open(file).expect("File open fail."); let reader = BufReader::new(input); let lines: Vec<String> = reader.lines() .filter_map(Result::ok) .collect(); let mut rooms = Vec::new(); let mut sum = 0; for line in lines { let mut words = line.split("-").col...
identifier_body
integer-literal-suffix-inference.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 ...
(n: uint) -> uint { n } fn id_u8(n: u8) -> u8 { n } fn id_u16(n: u16) -> u16 { n } fn id_u32(n: u32) -> u32 { n } fn id_u64(n: u64) -> u64 { n } let _i: i8 = -128; let j = -128; id_i8(j); id_i8(-128); let _i: i16 = -32_768; let j = -32_768; id_i16(j); id_i16(-32_768); ...
id_uint
identifier_name
integer-literal-suffix-inference.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
let _i: i8 = -128; let j = -128; id_i8(j); id_i8(-128); let _i: i16 = -32_768; let j = -32_768; id_i16(j); id_i16(-32_768); let _i: i32 = -2_147_483_648; let j = -2_147_483_648; id_i32(j); id_i32(-2_147_483_648); let _i: i64 = -9_223_372_036_854_775_808; let j...
fn id_uint(n: uint) -> uint { n } fn id_u8(n: u8) -> u8 { n } fn id_u16(n: u16) -> u16 { n } fn id_u32(n: u32) -> u32 { n } fn id_u64(n: u64) -> u64 { n }
random_line_split
integer-literal-suffix-inference.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 id_u64(n: u64) -> u64 { n } let _i: i8 = -128; let j = -128; id_i8(j); id_i8(-128); let _i: i16 = -32_768; let j = -32_768; id_i16(j); id_i16(-32_768); let _i: i32 = -2_147_483_648; let j = -2_147_483_648; id_i32(j); id_i32(-2_147_483_648); let _i: i64 = -...
{ n }
identifier_body
routing.rs
// Evelyn: Your personal assistant, project manager and calendar // Copyright (C) 2017 Gregory Jensen
// (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a...
// // This program 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
random_line_split
routing.rs
// Evelyn: Your personal assistant, project manager and calendar // Copyright (C) 2017 Gregory Jensen // // This program 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 //...
{ pub response_body: String, } pub struct Router { rules: HashMap<String, fn(RouterInput, Arc<ProcessorData>) -> RouterOutput>, } impl Router { pub fn new() -> Self { Router { rules: HashMap::new(), } } pub fn add_rule( &mut self, route: &str, ...
RouterOutput
identifier_name
routing.rs
// Evelyn: Your personal assistant, project manager and calendar // Copyright (C) 2017 Gregory Jensen // // This program 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 //...
, } } }
{ let model: model::ErrorModel = From::from(error_messages::EvelynServiceError::ReqestForActionWhichEvelynDoesNotKnowHowToDo(error_messages::EvelynBaseError::NothingElse)); Some(RouterOutput { response_body: serde_json::to_string(&model).unwrap(), ...
conditional_block
c-stack-returning-int64.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 ...
() { assert_eq!(atol(~"1024") * 10, atol(~"10240")); assert!((atoll(~"11111111111111111") * 10) == atoll(~"111111111111111110")); }
main
identifier_name
c-stack-returning-int64.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 main() { assert_eq!(atol(~"1024") * 10, atol(~"10240")); assert!((atoll(~"11111111111111111") * 10) == atoll(~"111111111111111110")); }
{ s.with_c_str(|x| unsafe { libc::atoll(x) as i64 }) }
identifier_body
c-stack-returning-int64.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 atol(s: ~str) -> int { s.with_c_str(|x| unsafe { libc::atol(x) as int }) } #[fixed_stack_segment] fn atoll(s: ~str) -> i64 { s.with_c_str(|x| unsafe { libc::atoll(x) as i64 }) } pub fn main() { assert_eq!(atol(~"1024") * 10, atol(~"10240")); assert!((atoll(~"11111111111111111") * 10) == atoll(~"111...
} } #[fixed_stack_segment]
random_line_split
main.rs
#[macro_use] extern crate serde_derive; extern crate serde; extern crate serde_json; extern crate tempfile; extern crate reqwest; extern crate git2; extern crate url; #[macro_use] extern crate clap; #[macro_use] extern crate nom; #[macro_use] extern crate log; extern crate env_logger; extern crate notify; mod cli; mod...
(&self) -> String { let mut buf = String::new(); fn wrap<T>(item: &T) -> String where T: Serialize { json::to_string_pretty(item).unwrap() } buf.push_str(&*format!(r#"{{ //Required. The name of the repository "name": {name}, //A short descrip...
to_template
identifier_name
main.rs
#[macro_use] extern crate serde_derive; extern crate serde; extern crate serde_json; extern crate tempfile; extern crate reqwest; extern crate git2; extern crate url; #[macro_use] extern crate clap; #[macro_use] extern crate nom; #[macro_use] extern crate log; extern crate env_logger; extern crate notify; mod cli; mod...
let request_params = request_params.unwrap(); // TODO: Need to handle errors from Github api let api_url = "https://api.github.com/user/repos"; let client = Client::new().unwrap(); let res: CreateResponse = client.post(api_url) .header(Authorization(Basic{ username: options.aut...
{ println!("Request parameters not saved, repository not created."); return; }
conditional_block
main.rs
#[macro_use] extern crate serde_derive; extern crate serde; extern crate serde_json; extern crate tempfile; extern crate reqwest; extern crate git2; extern crate url; #[macro_use] extern crate clap; #[macro_use] extern crate nom; #[macro_use] extern crate log; extern crate env_logger; extern crate notify; mod cli; mod...
has_downloads: bool, auto_init: bool, gitignore_template: String, license_template: String, } impl Default for CreateRequest { fn default() -> CreateRequest { CreateRequest { name: "".into(), description: "".into(), homepage: "".into(), privat...
has_wiki: bool,
random_line_split
main.rs
#[macro_use] extern crate serde_derive; extern crate serde; extern crate serde_json; extern crate tempfile; extern crate reqwest; extern crate git2; extern crate url; #[macro_use] extern crate clap; #[macro_use] extern crate nom; #[macro_use] extern crate log; extern crate env_logger; extern crate notify; mod cli; mod...
buf.push_str(&*format!(r#"{{ //Required. The name of the repository "name": {name}, //A short description of the repository "description": {description}, //A URL with more information about the repository "homepage": {homepage}, //Set to true to create a private repository "pri...
{ json::to_string_pretty(item).unwrap() }
identifier_body
lib.rs
#![feature(collections)] extern crate collections; pub mod parser { use collections::fmt::{Formatter, Result}; use std::fmt::Debug; use collections::str::Chars; use std::collections::BTreeMap; use std::string; pub enum Json { String(string::String), Object(self::Object), ...
fn parse_string(it: &mut Chars) -> String { let mut string = "".to_string(); loop { match it.next() { Some('"') => { break; }, Some('\\') => continue, Some(c) => string.push(c), None => p...
random_line_split
lib.rs
#![feature(collections)] extern crate collections; pub mod parser { use collections::fmt::{Formatter, Result}; use std::fmt::Debug; use collections::str::Chars; use std::collections::BTreeMap; use std::string; pub enum Json { String(string::String), Object(self::Object), ...
(it: &mut Chars) -> Json { let mut ar: Array = vec![parse_value(it)]; loop { match it.next() { Some(']') => break, None => break, Some(',') => ar.push(parse_value(it)), Some(_) => continue } } Json::...
parse_array
identifier_name
lib.rs
#![feature(collections)] extern crate collections; pub mod parser { use collections::fmt::{Formatter, Result}; use std::fmt::Debug; use collections::str::Chars; use std::collections::BTreeMap; use std::string; pub enum Json { String(string::String), Object(self::Object), ...
{ }
identifier_body
p011.rs
use std::cmp; pub fn solve() -> i32 { const S: &'static str = r" 08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08 49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00 81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 13 36 65 52 70 95 23 04 60 11 42 69 24 68 56 01 32 56 71 37 02 36 91 22 31 16 7...
ret } // right -> left fn cal3(vvi: &Vec<Vec<i32>>, x: usize, y: usize) -> i32 { let mut ret = vvi[x][y]; if x as i32 - 1 >= 0 && y + 1 < vvi[0].len() && x + 1 < vvi.len() && y as i32 - 1 >=0 && x + 2 < vvi.len() && y as i32 - 2 >= 0 { ret *= vvi[x - 1][y + 1] * vvi[x + 1][y - 1] * vvi[x + 2][y - 2]; } r...
{ ret *= vvi[x - 1][y - 1] * vvi[x + 1][y + 1] * vvi[x + 2][y + 2]; }
conditional_block