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 |
|---|---|---|---|---|
revaultd.rs | bitcoin::{
secp256k1,
util::bip32::{ChildNumber, ExtendedPubKey},
Address, BlockHash, PublicKey as BitcoinPublicKey, Script, TxOut,
},
miniscript::descriptor::{DescriptorPublicKey, DescriptorTrait},
scripts::{
CpfpDescriptor, DepositDescriptor, DerivedCpfpDescriptor, Deriv... |
/// Our Noise static public key
pub fn noise_pubkey(&self) -> NoisePubKey {
let scalar = curve25519::Scalar(self.noise_secret.0);
NoisePubKey(curve25519::scalarmult_base(&scalar).0)
}
pub fn vault_address(&self, child_number: ChildNumber) -> Address {
self.deposit_descriptor
... | {
let data_dir_str = self
.data_dir
.to_str()
.expect("Impossible: the datadir path is valid unicode");
[data_dir_str, file_name].iter().collect()
} | identifier_body |
page.rs | use serde::Deserialize;
use yew::format::{Json, Nothing};
use yew::prelude::*;
use yew::services::fetch::{FetchService, FetchTask, Request, Response};
use yew::services::ConsoleService;
use yew::Properties;
use super::entry::{Entry, EntryProps};
use super::modal::{is_media, MediaType, Modal, ModalProps};
use crate::{A... | (&mut self, msg: Self::Message) -> ShouldRender {
match msg {
PageMsg::Page(page) => {
self.props.page = Some(page);
self.error = None;
self.show_loading = false;
true
}
// TODO: This means non-media (non-modal d... | update | identifier_name |
page.rs | use serde::Deserialize;
use yew::format::{Json, Nothing};
use yew::prelude::*;
use yew::services::fetch::{FetchService, FetchTask, Request, Response};
use yew::services::ConsoleService;
use yew::Properties;
use super::entry::{Entry, EntryProps};
use super::modal::{is_media, MediaType, Modal, ModalProps};
use crate::{A... | } else {
html! {}
};
let error = if self.error.is_some() {
html! {<h2 class="text-danger">{ "Error: " }{ self.error.as_ref().unwrap() }</h2>}
} else {
html! {}
};
html! {
<>
<Modal src={ self.modal.src.to_o... | });
let loading = if self.show_loading {
html! {<span class="loading"></span>} | random_line_split |
page.rs | use serde::Deserialize;
use yew::format::{Json, Nothing};
use yew::prelude::*;
use yew::services::fetch::{FetchService, FetchTask, Request, Response};
use yew::services::ConsoleService;
use yew::Properties;
use super::entry::{Entry, EntryProps};
use super::modal::{is_media, MediaType, Modal, ModalProps};
use crate::{A... |
PageMsg::ModalNext => {
let src = format!("/{}", self.next_file());
App::change_route(src);
true
}
PageMsg::ModalPrevious => {
let src = format!("/{}", self.prev_file());
App::change_route(src);
... | {
ConsoleService::info(format!("Loading modal for: {:?}", src).as_str());
self.modal.src = src.to_string();
self.modal.media = MediaType::from_path(src.as_str());
self.show_loading = false;
true
} | conditional_block |
lib.rs | use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize};
use near_sdk::collections::UnorderedMap;
use near_sdk::serde::{Deserialize, Serialize};
use near_contract_standards::non_fungible_token::metadata::{
NFTContractMetadata, NonFungibleTokenMetadataProvider, TokenMetadata, NFT_METADATA_SPEC,
};
use near_co... |
}
const DATA_IMAGE_SVG_NEAR_ICON: &str = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 288 288'%3E%3Cg id='l' data-name='l'%3E%3Cpath d='M187.58,79.81l-30.1,44.69a3.2,3.2,0,0,0,4.75,4.2L191.86,103a1.2,1.2,0,0,1,2,.91v80.46a1.2,1.2,0,0,1-2.12.77L102.18,77.93A15.35,15.35,0,0,0,90.47,72.5H87... | {
env::panic(b"SmartCertificate contract should be initialized before usage")
} | identifier_body |
lib.rs | use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize};
use near_sdk::collections::UnorderedMap;
use near_sdk::serde::{Deserialize, Serialize};
use near_contract_standards::non_fungible_token::metadata::{
NFTContractMetadata, NonFungibleTokenMetadataProvider, TokenMetadata, NFT_METADATA_SPEC,
};
use near_co... |
return false;
}
pub fn create_cert(&mut self, user_account_id: ValidAccountId, name: String, dob: String, national_id: String) {
self.assert_called_by_issuers();
let issuer = self.issuers.get(&env::predecessor_account_id()).clone().unwrap();
let user = UserInfo {
n... | {
let new_issuer = Issuer {
name: name,
issuer_id: issuer_account.clone(),
};
self.issuers.insert(&issuer_account, &new_issuer);
return true;
} | conditional_block |
lib.rs | use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize};
use near_sdk::collections::UnorderedMap;
use near_sdk::serde::{Deserialize, Serialize};
use near_contract_standards::non_fungible_token::metadata::{
NFTContractMetadata, NonFungibleTokenMetadataProvider, TokenMetadata, NFT_METADATA_SPEC,
};
use near_co... | assert!(
env::is_valid_account_id(issuer_account.as_bytes()),
"The given account ID is invalid"
);
self.assert_called_by_foundation();
if!self.issuers.get(&issuer_account).is_some() {
let new_issuer = Issuer {
name: name,
... | pub fn add_issuer(&mut self, issuer_account: AccountId, name: String) -> bool { | random_line_split |
lib.rs | use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize};
use near_sdk::collections::UnorderedMap;
use near_sdk::serde::{Deserialize, Serialize};
use near_contract_standards::non_fungible_token::metadata::{
NFTContractMetadata, NonFungibleTokenMetadataProvider, TokenMetadata, NFT_METADATA_SPEC,
};
use near_co... | (&mut self, issuer_account: AccountId, name: String) -> bool {
assert!(
env::is_valid_account_id(issuer_account.as_bytes()),
"The given account ID is invalid"
);
self.assert_called_by_foundation();
if!self.issuers.get(&issuer_account).is_some() {
let... | add_issuer | identifier_name |
args.rs | // Copyright 2016 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 ... | (argc: isize, argv: *const *const u8) {
let args = (0..argc).map(|i| {
CStr::from_ptr(*argv.offset(i) as *const libc::c_char).to_bytes().to_vec()
}).collect();
LOCK.lock();
let ptr = get_global_ptr();
assert!((*ptr).is_none());
(*ptr) = Some(box args);
... | init | identifier_name |
args.rs | // Copyright 2016 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 next_back(&mut self) -> Option<OsString> { self.iter.next_back() }
}
mod imp {
use os::unix::prelude::*;
use mem;
use ffi::{CStr, OsString};
use marker::PhantomData;
use libc;
use super::Args;
use sys_common::mutex::Mutex;
static mut GLOBAL_ARGS_PTR: usize = 0;
static LOCK:... | impl DoubleEndedIterator for Args { | random_line_split |
args.rs | // Copyright 2016 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 ... |
}
impl Iterator for Args {
type Item = OsString;
fn next(&mut self) -> Option<OsString> { self.iter.next() }
fn size_hint(&self) -> (usize, Option<usize>) { self.iter.size_hint() }
}
impl ExactSizeIterator for Args {
fn len(&self) -> usize { self.iter.len() }
}
impl DoubleEndedIterator for Args {
... | {
self.iter.as_slice()
} | identifier_body |
windows_1257.rs | // AUTOGENERATED FROM index-windows-1257.txt, ORIGINAL COMMENT FOLLOWS:
//
// Any copyright is dedicated to the Public Domain.
// http://creativecommons.org/publicdomain/zero/1.0/
//
// For details on index-windows-1257.txt see the Encoding Standard
// http://encoding.spec.whatwg.org/
static FORWARD_TABLE: &'static [u... | else {0};
BACKWARD_TABLE_LOWER[offset + ((code & 63) as uint)]
}
#[cfg(test)]
single_byte_tests!()
| {BACKWARD_TABLE_UPPER[offset] as uint} | conditional_block |
windows_1257.rs | // AUTOGENERATED FROM index-windows-1257.txt, ORIGINAL COMMENT FOLLOWS:
//
// Any copyright is dedicated to the Public Domain.
// http://creativecommons.org/publicdomain/zero/1.0/
//
// For details on index-windows-1257.txt see the Encoding Standard
// http://encoding.spec.whatwg.org/
static FORWARD_TABLE: &'static [u... |
static BACKWARD_TABLE_LOWER: &'static [u8] = &[
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 129, 0, 131, 0, 0, 0, 0, 136,
0, 138, 0, 140, 0, 0, 0, 144,... | {
FORWARD_TABLE[(code - 0x80) as uint]
} | identifier_body |
windows_1257.rs | // AUTOGENERATED FROM index-windows-1257.txt, ORIGINAL COMMENT FOLLOWS:
//
// Any copyright is dedicated to the Public Domain.
// http://creativecommons.org/publicdomain/zero/1.0/
//
// For details on index-windows-1257.txt see the Encoding Standard
// http://encoding.spec.whatwg.org/
static FORWARD_TABLE: &'static [u... | (code: u32) -> u8 {
let offset = (code >> 6) as uint;
let offset = if offset < 133 {BACKWARD_TABLE_UPPER[offset] as uint} else {0};
BACKWARD_TABLE_LOWER[offset + ((code & 63) as uint)]
}
#[cfg(test)]
single_byte_tests!()
| backward | identifier_name |
windows_1257.rs | // AUTOGENERATED FROM index-windows-1257.txt, ORIGINAL COMMENT FOLLOWS:
//
// Any copyright is dedicated to the Public Domain.
// http://creativecommons.org/publicdomain/zero/1.0/
//
// For details on index-windows-1257.txt see the Encoding Standard
// http://encoding.spec.whatwg.org/
static FORWARD_TABLE: &'static [u... | 149, 0, 0, 0, 133, 0, 0, 0, 0, 0, 0, 0, 0, 0, 137, 0, 0, 0, 0, 0, 0, 0, 0,
139, 155, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
... | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 150, 151, 0, 0, 0, 145, 146, 130, 0, 147, 148, 132, 0, 134, 135, | random_line_split |
props.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 dbus::arg::IterAppend;
use dbus_tree::{MTSync, MethodErr, PropInfo};
use crate::{
dbus_api::{
filesy... | where
E: Engine,
{
get_filesystem_property(i, p, |(_, fs_name, _)| Ok(shared::fs_name_prop(&fs_name)))
}
/// Get the creation date and time in rfc3339 format.
pub fn get_filesystem_created<E>(
i: &mut IterAppend<'_>,
p: &PropInfo<'_, MTSync<TData<E>>, TData<E>>,
) -> Result<(), MethodErr>
where
E: ... | pub fn get_filesystem_name<E>(
i: &mut IterAppend<'_>,
p: &PropInfo<'_, MTSync<TData<E>>, TData<E>>,
) -> Result<(), MethodErr> | random_line_split |
props.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 dbus::arg::IterAppend;
use dbus_tree::{MTSync, MethodErr, PropInfo};
use crate::{
dbus_api::{
filesy... |
pub fn get_filesystem_name<E>(
i: &mut IterAppend<'_>,
p: &PropInfo<'_, MTSync<TData<E>>, TData<E>>,
) -> Result<(), MethodErr>
where
E: Engine,
{
get_filesystem_property(i, p, |(_, fs_name, _)| Ok(shared::fs_name_prop(&fs_name)))
}
/// Get the creation date and time in rfc3339 format.
pub fn get_fil... | {
get_filesystem_property(i, p, |(pool_name, fs_name, fs)| {
Ok(shared::fs_devnode_prop::<E>(fs, &pool_name, &fs_name))
})
} | identifier_body |
props.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 dbus::arg::IterAppend;
use dbus_tree::{MTSync, MethodErr, PropInfo};
use crate::{
dbus_api::{
filesy... | <F, R, E>(
i: &mut IterAppend<'_>,
p: &PropInfo<'_, MTSync<TData<E>>, TData<E>>,
getter: F,
) -> Result<(), MethodErr>
where
F: Fn((Name, Name, &<E::Pool as Pool>::Filesystem)) -> Result<R, String>,
R: dbus::arg::Append,
E: Engine,
{
#[allow(clippy::redundant_closure)]
i.append(
... | get_filesystem_property | identifier_name |
engine.rs | //! A solver for dataflow problems.
use std::borrow::BorrowMut;
use std::ffi::OsString;
use std::path::PathBuf;
use rustc_ast as ast;
use rustc_data_structures::work_queue::WorkQueue;
use rustc_graphviz as dot;
use rustc_hir::def_id::DefId;
use rustc_index::bit_set::BitSet;
use rustc_index::vec::{Idx, IndexVec};
use ... |
/// Computes the fixpoint for this dataflow problem and returns it.
pub fn iterate_to_fixpoint(self) -> Results<'tcx, A>
where
A::Domain: DebugWithContext<A>,
{
let Engine {
analysis,
body,
dead_unwinds,
mut entry_sets,
tcx,
... | {
self.pass_name = Some(name);
self
} | identifier_body |
engine.rs | //! A solver for dataflow problems.
use std::borrow::BorrowMut;
use std::ffi::OsString;
use std::path::PathBuf;
use rustc_ast as ast;
use rustc_data_structures::work_queue::WorkQueue;
use rustc_graphviz as dot;
use rustc_hir::def_id::DefId;
use rustc_index::bit_set::BitSet;
use rustc_index::vec::{Idx, IndexVec};
use ... | (self) -> Results<'tcx, A>
where
A::Domain: DebugWithContext<A>,
{
let Engine {
analysis,
body,
dead_unwinds,
mut entry_sets,
tcx,
apply_trans_for_block,
pass_name,
..
} = self;
let mu... | iterate_to_fixpoint | identifier_name |
engine.rs | //! A solver for dataflow problems.
use std::borrow::BorrowMut;
use std::ffi::OsString;
use std::path::PathBuf;
use rustc_ast as ast;
use rustc_data_structures::work_queue::WorkQueue;
use rustc_graphviz as dot;
use rustc_hir::def_id::DefId;
use rustc_index::bit_set::BitSet;
use rustc_index::vec::{Idx, IndexVec};
use ... | tcx: TyCtxt<'tcx>,
body: &mir::Body<'tcx>,
results: &Results<'tcx, A>,
pass_name: Option<&'static str>,
) -> std::io::Result<()>
where
A: Analysis<'tcx>,
A::Domain: DebugWithContext<A>,
{
use std::fs;
use std::io::{self, Write};
let def_id = body.source.def_id();
let attrs = mat... | /// `rustc_mir` attributes.
fn write_graphviz_results<A>( | random_line_split |
as_unsigned_mut.rs | #![feature(core)]
extern crate core;
#[cfg(test)]
mod tests {
use core::slice::IntSliceExt;
// pub trait IntSliceExt<U, S> {
// /// Converts the slice to an immutable slice of unsigned integers with the same width.
// fn as_unsigned<'a>(&'a self) -> &'a [U];
// /// Converts the slice t... | () {
let slice: &mut [T] = &mut [0];
{
let as_unsigned_mut: &mut [U] = slice.as_unsigned_mut();
as_unsigned_mut[0] = 0xff;
}
assert_eq!(slice, &mut[-1]);
}
}
| as_unsigned_mut_test1 | identifier_name |
as_unsigned_mut.rs | #![feature(core)]
extern crate core;
#[cfg(test)]
mod tests {
use core::slice::IntSliceExt;
// pub trait IntSliceExt<U, S> {
// /// Converts the slice to an immutable slice of unsigned integers with the same width.
// fn as_unsigned<'a>(&'a self) -> &'a [U];
// /// Converts the slice t... |
}
| {
let slice: &mut [T] = &mut [0];
{
let as_unsigned_mut: &mut [U] = slice.as_unsigned_mut();
as_unsigned_mut[0] = 0xff;
}
assert_eq!(slice, &mut[-1]);
} | identifier_body |
as_unsigned_mut.rs | #![feature(core)]
extern crate core; | // pub trait IntSliceExt<U, S> {
// /// Converts the slice to an immutable slice of unsigned integers with the same width.
// fn as_unsigned<'a>(&'a self) -> &'a [U];
// /// Converts the slice to an immutable slice of signed integers with the same width.
// fn as_signed<'a>(&'a self)... |
#[cfg(test)]
mod tests {
use core::slice::IntSliceExt;
| random_line_split |
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 ... | <'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
span: Span,
method_name: ast::Name,
self_ty: Ty<'tcx>,
expr_id: ast::NodeId)
-> Result<(def::Def, LastPrivate), MethodError>
{
let ... | resolve_ufcs | identifier_name |
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 ... | Ok(..) => true,
Err(NoMatch(..)) => false,
Err(Ambiguity(..)) => true,
Err(ClosureAmbiguity(..)) => true,
}
}
/// Performs method lookup. If lookup is successful, it will return the callee and store an
/// appropriate adjustment for the self-expr. In some cases it may report an erro... | {
let mode = probe::Mode::MethodCall;
match probe::probe(fcx, span, mode, method_name, self_ty, call_expr_id) { | random_line_split |
prewitt.rs | use rgb::*;
use imgref::*;
use loop9::{Triple,loop9};
pub trait ToGray {
fn to_gray(self) -> i16;
}
impl ToGray for RGBA8 {
fn to_gray(self) -> i16 {
self.rgb().to_gray()
}
}
impl ToGray for RGB8 {
fn to_gray(self) -> i16 {
let px = self.map(|c| c as i16);
px.r + px.g + px.g + p... | }
#[inline]
pub fn prewitt_squared3<T: Into<i16>>(top: Triple<T>, mid: Triple<T>, bot: Triple<T>) -> u16 {
prewitt_squared(top.prev, top.curr, top.next, mid.prev, mid.next, bot.prev, bot.curr, bot.next)
}
#[inline]
pub fn prewitt_squared<T: Into<i16>>(top_prev: T, top_curr: T, top_next: T, mid_prev: T, mid_next: ... | loop9(gray.as_ref(), 0,0, gray.width(), gray.height(), |_x,_y,top,mid,bot|{
prew.push(prewitt_squared3(top, mid, bot));
});
ImgVec::new(prew, gray.width(), gray.height()) | random_line_split |
prewitt.rs | use rgb::*;
use imgref::*;
use loop9::{Triple,loop9};
pub trait ToGray {
fn to_gray(self) -> i16;
}
impl ToGray for RGBA8 {
fn to_gray(self) -> i16 {
self.rgb().to_gray()
}
}
impl ToGray for RGB8 {
fn | (self) -> i16 {
let px = self.map(|c| c as i16);
px.r + px.g + px.g + px.b
}
}
pub fn prewitt_squared_img<T: ToGray + Copy>(input: ImgRef<'_, T>) -> ImgVec<u16> {
let gray: Vec<_> = input.pixels().map(|px|px.to_gray()).collect();
let gray = Img::new(gray, input.width(), input.height());
... | to_gray | identifier_name |
prewitt.rs | use rgb::*;
use imgref::*;
use loop9::{Triple,loop9};
pub trait ToGray {
fn to_gray(self) -> i16;
}
impl ToGray for RGBA8 {
fn to_gray(self) -> i16 {
self.rgb().to_gray()
}
}
impl ToGray for RGB8 {
fn to_gray(self) -> i16 {
let px = self.map(|c| c as i16);
px.r + px.g + px.g + p... |
#[inline]
pub fn prewitt_squared<T: Into<i16>>(top_prev: T, top_curr: T, top_next: T, mid_prev: T, mid_next: T, bot_prev: T, bot_curr: T, bot_next: T) -> u16 {
let top_prev = top_prev.into();
let top_curr = top_curr.into();
let top_next = top_next.into();
let mid_prev = mid_prev.into();
let mid_ne... | {
prewitt_squared(top.prev, top.curr, top.next, mid.prev, mid.next, bot.prev, bot.curr, bot.next)
} | identifier_body |
snmp-decode.rs | extern crate asn1_cereal;
extern crate argparse;
extern crate serde;
extern crate serde_json;
use asn1_cereal::{tag, byte};
use asn1_cereal::ber::stream;
// SNMP ASN.1 Definition
// https://tools.ietf.org/html/rfc1157#page-30
type ObjectIdentifier = u64;
type NetworkAddress = u64;
type ObjectName = String;
struct M... |
struct GetNextRequest(PDU);
struct GetResponse(PDU);
struct SetRequest(PDU);
struct PDU {
request_id: i32,
error_status: i32,
error_index: i32,
variable_bindings: VarBindList,
}
struct TrapPDU {
enterprise: ObjectIdentifier,
agent_addr: NetworkAddress,
generic_trap: i32,
specific_trap: i32,
time_... | struct GetRequest(PDU); | random_line_split |
snmp-decode.rs | extern crate asn1_cereal;
extern crate argparse;
extern crate serde;
extern crate serde_json;
use asn1_cereal::{tag, byte};
use asn1_cereal::ber::stream;
// SNMP ASN.1 Definition
// https://tools.ietf.org/html/rfc1157#page-30
type ObjectIdentifier = u64;
type NetworkAddress = u64;
type ObjectName = String;
struct M... |
// Create a buffered reader from the file.
let reader = io::BufReader::new(fs::File::open(path).unwrap()).bytes();
}
struct ProgOpts {
file: Option<String>,
verbose: bool,
}
fn parse_args() -> ProgOpts {
let mut opts = ProgOpts {
file: None,
verbose: false,
};
{
let mut ap = ArgumentParse... | {
panic!("Supplied file does not exist");
} | conditional_block |
snmp-decode.rs | extern crate asn1_cereal;
extern crate argparse;
extern crate serde;
extern crate serde_json;
use asn1_cereal::{tag, byte};
use asn1_cereal::ber::stream;
// SNMP ASN.1 Definition
// https://tools.ietf.org/html/rfc1157#page-30
type ObjectIdentifier = u64;
type NetworkAddress = u64;
type ObjectName = String;
struct M... | (PDU);
struct SetRequest(PDU);
struct PDU {
request_id: i32,
error_status: i32,
error_index: i32,
variable_bindings: VarBindList,
}
struct TrapPDU {
enterprise: ObjectIdentifier,
agent_addr: NetworkAddress,
generic_trap: i32,
specific_trap: i32,
time_stamp: TimeTicks,
variable_bindings: VarBindLi... | GetResponse | identifier_name |
edit_role.rs | use std::collections::HashMap;
use bytes::buf::Buf;
use reqwest::Url;
use tokio::{fs::File, io::AsyncReadExt};
use crate::http::{AttachmentType, Http};
use crate::internal::prelude::*;
use crate::model::{guild::Role, Permissions};
/// A builder to create or edit a [`Role`] for use via a number of model methods.
///
... | (&mut self, position: u8) -> &mut Self {
self.0.insert("position", Value::Number(Number::from(position)));
self
}
/// The unicode emoji to set as the role image.
pub fn unicode_emoji<S: ToString>(&mut self, unicode_emoji: S) -> &mut Self {
self.0.remove("icon");
self.0.inser... | position | identifier_name |
edit_role.rs | use std::collections::HashMap;
use bytes::buf::Buf;
use reqwest::Url;
use tokio::{fs::File, io::AsyncReadExt};
use crate::http::{AttachmentType, Http};
use crate::internal::prelude::*;
use crate::model::{guild::Role, Permissions};
/// A builder to create or edit a [`Role`] for use via a number of model methods.
///
... |
EditRole(map)
}
/// Sets the colour of the role.
pub fn colour(&mut self, colour: u64) -> &mut Self {
self.0.insert("color", Value::Number(Number::from(colour)));
self
}
/// Whether or not to hoist the role above lower-positioned role in the user
/// list.
pub fn ... | {
map.insert("icon", Value::String(icon.clone()));
} | conditional_block |
edit_role.rs | use std::collections::HashMap;
use bytes::buf::Buf;
use reqwest::Url;
use tokio::{fs::File, io::AsyncReadExt};
use crate::http::{AttachmentType, Http};
use crate::internal::prelude::*;
use crate::model::{guild::Role, Permissions};
/// A builder to create or edit a [`Role`] for use via a number of model methods.
///
... |
/// The set of permissions to assign the role.
pub fn permissions(&mut self, permissions: Permissions) -> &mut Self {
self.0.insert("permissions", Value::Number(Number::from(permissions.bits())));
self
}
/// The position to assign the role in the role list. This correlates to the
... | {
self.0.insert("name", Value::String(name.to_string()));
self
} | identifier_body |
edit_role.rs | use std::collections::HashMap;
use bytes::buf::Buf;
use reqwest::Url;
use tokio::{fs::File, io::AsyncReadExt};
use crate::http::{AttachmentType, Http};
use crate::internal::prelude::*;
use crate::model::{guild::Role, Permissions};
/// A builder to create or edit a [`Role`] for use via a number of model methods.
///
... | self.0.insert("permissions", Value::Number(Number::from(permissions.bits())));
self
}
/// The position to assign the role in the role list. This correlates to the
/// role's position in the user list.
pub fn position(&mut self, position: u8) -> &mut Self {
self.0.insert("positio... |
/// The set of permissions to assign the role.
pub fn permissions(&mut self, permissions: Permissions) -> &mut Self { | random_line_split |
mod.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/. */
pub use self::builder::BlockFlowDisplayListBuilding;
pub use self::builder::BorderPaintingMode;
pub use self::buil... | mod background;
mod builder;
mod conversions;
pub mod items;
mod webrender_helpers; | pub use self::builder::StackingContextCollectionFlags;
pub use self::builder::StackingContextCollectionState;
pub use self::conversions::ToLayout;
pub use self::webrender_helpers::WebRenderDisplayListConverter;
| random_line_split |
font_face.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 [`@font-face`][ff] at-rule.
//!
//! [ff]: https://drafts.csswg.org/css-fonts/#at-font-face-rule
#![deny(m... | else {
true
}
}).cloned().collect())
}
}
impl iter::Iterator for EffectiveSources {
type Item = Source;
fn next(&mut self) -> Option<Source> {
self.0.pop()
}
}
struct FontFaceRuleParser<'a, 'b: 'a> {
context: &'a ParserContext<'b>,
rule: &'a mut Fon... | {
let hints = &url_source.format_hints;
// We support only opentype fonts and truetype is an alias for
// that format. Sources without format hints need to be
// downloaded in case we support them.
hints.is_empty() || hints.iter().any(|hint... | conditional_block |
font_face.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 [`@font-face`][ff] at-rule.
//!
//! [ff]: https://drafts.csswg.org/css-fonts/#at-font-face-rule
#![deny(m... | {
/// The specified url.
pub url: SpecifiedUrl,
/// The format hints specified with the `format()` function.
pub format_hints: Vec<String>,
}
impl ToCss for UrlSource {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result
where W: fmt::Write,
{
dest.write_str(self.url.as_str())
... | UrlSource | identifier_name |
font_face.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 [`@font-face`][ff] at-rule.
//!
//! [ff]: https://drafts.csswg.org/css-fonts/#at-font-face-rule
#![deny(m... | Ok(Source::Url(UrlSource {
url: url,
format_hints: format_hints,
}))
}
}
macro_rules! font_face_descriptors {
(
mandatory descriptors = [
$( #[$m_doc: meta] $m_name: tt $m_ident: ident: $m_ty: ty = $m_initial: expr, )*
]
optional desc... | {
if input.try(|input| input.expect_function_matching("local")).is_ok() {
return input.parse_nested_block(|input| {
FamilyName::parse(context, input)
}).map(Source::Local)
}
let url = SpecifiedUrl::parse(context, input)?;
// Parsing optional form... | identifier_body |
font_face.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 [`@font-face`][ff] at-rule.
//!
//! [ff]: https://drafts.csswg.org/css-fonts/#at-font-face-rule
#![deny(m... | }
}
impl FontFaceRule {
fn initial() -> Self {
FontFaceRule {
$(
$m_ident: $m_initial,
)*
$(
$o_ident: $o_initial,
)*
}... | self.$m_ident
)||* | random_line_split |
intersection.rs | // Copyright 2018 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in ... | {
pub id: IntersectionID,
pub point: Vec2d,
polygon: Vec<Vec2d>,
}
impl DrawIntersection {
pub fn new(
inter: &map_model::Intersection,
map: &Map,
roads: &Vec<DrawRoad>,
bounds: &Bounds,
) -> DrawIntersection {
let mut pts: Vec<Vec2d> = Vec::new();
... | DrawIntersection | identifier_name |
intersection.rs | // Copyright 2018 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in ... |
polygon: Vec<Vec2d>,
}
impl DrawIntersection {
pub fn new(
inter: &map_model::Intersection,
map: &Map,
roads: &Vec<DrawRoad>,
bounds: &Bounds,
) -> DrawIntersection {
let mut pts: Vec<Vec2d> = Vec::new();
// TODO this smashes encapsulation to bits :D
... | pub point: Vec2d, | random_line_split |
intersection.rs | // Copyright 2018 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in ... |
angle as i64
});
let first_pt = pts[0].clone();
pts.push(first_pt);
DrawIntersection {
id: inter.id,
point: [center.x(), center.y()],
polygon: pts,
}
}
pub fn draw(&self, g: &mut GfxCtx, color: Color) {
let poly =... | {
angle += 360.0;
} | conditional_block |
partial_file.rs | // Copyright (c) 2017 Simon Dickson
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
use std::cmp;
use std::fs::File;
use std::io::{self, BufReader, SeekFrom, See... | let mut partial_content = BufReader::new(self.file);
let _ = partial_content.seek(SeekFrom::Start(range.0));
let result = partial_content.take(content_len);
response.set_status(Status::PartialContent);
response.set_streamed_body(result);
} else {
... | response.set_header(ContentLength(content_len));
response.set_header(content_range); | random_line_split |
partial_file.rs | // Copyright (c) 2017 Simon Dickson
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
use std::cmp;
use std::fs::File;
use std::io::{self, BufReader, SeekFrom, See... | else {
if let Some(file_length) = file_length {
response.set_header(ContentRange(ContentRangeSpec::Bytes {
range: None,
instance_length: Some(file_length),
}));
};
response.set_status(Status::RangeNotSatisfiable... | {
let content_range = ContentRange(ContentRangeSpec::Bytes {
range: Some(range),
instance_length: file_length,
});
let content_len = range.1 - range.0 + 1;
response.set_header(ContentLength(content_len));
response.set_header(con... | conditional_block |
partial_file.rs | // Copyright (c) 2017 Simon Dickson
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
use std::cmp;
use std::fs::File;
use std::io::{self, BufReader, SeekFrom, See... | if last < file_length {
Some((file_length - last, file_length - 1))
} else {
Some((0, file_length - 1))
}
},
(_, None) => None,
};
if let Some(range) = range {
let con... | {
use self::PartialFileRange::*;
let metadata : Option<_> = self.file.metadata().ok();
let file_length : Option<u64> = metadata.map(|m| m.len());
let range : Option<(u64, u64)> = match (range.into(), file_length) {
(FromTo(from, to), Some(file_length)) => {
if... | identifier_body |
partial_file.rs | // Copyright (c) 2017 Simon Dickson
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
use std::cmp;
use std::fs::File;
use std::io::{self, BufReader, SeekFrom, See... | (video_path: &Path) -> io::Result<PartialFile> {
PartialFile::open(video_path)
}
| serve_partial | identifier_name |
s3.rs | // Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0.
use std::io;
use std::marker::PhantomData;
use futures_util::{
future::FutureExt,
io::{AsyncRead, AsyncReadExt},
stream::TryStreamExt,
};
use rusoto_core::{
request::DispatchSignedRequest,
{ByteStream, RusotoError},
};
use rusoto_... | "mykey",
Box::new(magic_contents.as_bytes()),
magic_contents.len() as u64,
)
.unwrap();
let mut reader = s.read("mykey");
let mut buf = Vec::new();
let ret = block_on_external_io(reader.read_to_end(&mut buf));
assert!(ret.unwrap() == 0);... | {
let magic_contents = "5678";
let config = Config {
region: "ap-southeast-2".to_string(),
bucket: "mybucket".to_string(),
prefix: "myprefix".to_string(),
access_key: "abc".to_string(),
secret_access_key: "xyz".to_string(),
..Defaul... | identifier_body |
s3.rs | // Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0.
use std::io;
use std::marker::PhantomData;
use futures_util::{
future::FutureExt,
io::{AsyncRead, AsyncReadExt},
stream::TryStreamExt,
};
use rusoto_core::{
request::DispatchSignedRequest,
{ByteStream, RusotoError},
};
use rusoto_... | }
/// Starts a multipart upload process.
async fn begin(&self) -> Result<String, RusotoError<CreateMultipartUploadError>> {
let output = self
.client
.create_multipart_upload(CreateMultipartUploadRequest {
bucket: self.bucket.clone(),
key: self.... | let _ = retry(|| self.abort()).await;
}
upload_res
} | random_line_split |
s3.rs | // Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0.
use std::io;
use std::marker::PhantomData;
use futures_util::{
future::FutureExt,
io::{AsyncRead, AsyncReadExt},
stream::TryStreamExt,
};
use rusoto_core::{
request::DispatchSignedRequest,
{ByteStream, RusotoError},
};
use rusoto_... | (&self) -> Result<(), RusotoError<AbortMultipartUploadError>> {
self.client
.abort_multipart_upload(AbortMultipartUploadRequest {
bucket: self.bucket.clone(),
key: self.key.clone(),
upload_id: self.upload_id.clone(),
..Default::default()
... | abort | identifier_name |
member_constraints.rs | use rustc_data_structures::fx::FxHashMap;
use rustc_index::vec::IndexVec;
use rustc_middle::infer::MemberConstraint;
use rustc_middle::ty::{self, Ty};
use rustc_span::Span;
use std::hash::Hash;
use std::ops::Index;
/// Compactly stores a set of `R0 member of [R1...Rn]` constraints,
/// indexed by the region `R0`.
crat... |
}
/// Given a linked list starting at `source_list` and another linked
/// list starting at `target_list`, modify `target_list` so that it is
/// followed by `source_list`.
///
/// Before:
///
/// ```
/// target_list: A -> B -> C -> (None)
/// source_list: D -> E -> F -> (None)
/// ```
///
/// After:
///
/// ```
/// ... | {
&self.constraints[i]
} | identifier_body |
member_constraints.rs | use rustc_data_structures::fx::FxHashMap;
use rustc_index::vec::IndexVec;
use rustc_middle::infer::MemberConstraint;
use rustc_middle::ty::{self, Ty};
use rustc_span::Span;
use std::hash::Hash;
use std::ops::Index;
/// Compactly stores a set of `R0 member of [R1...Rn]` constraints,
/// indexed by the region `R0`.
crat... | crate struct NllMemberConstraint<'tcx> {
next_constraint: Option<NllMemberConstraintIndex>,
/// The span where the hidden type was instantiated.
crate definition_span: Span,
/// The hidden type in which `R0` appears. (Used in error reporting.)
crate hidden_ty: Ty<'tcx>,
/// The region `R0`.
... | random_line_split | |
member_constraints.rs | use rustc_data_structures::fx::FxHashMap;
use rustc_index::vec::IndexVec;
use rustc_middle::infer::MemberConstraint;
use rustc_middle::ty::{self, Ty};
use rustc_span::Span;
use std::hash::Hash;
use std::ops::Index;
/// Compactly stores a set of `R0 member of [R1...Rn]` constraints,
/// indexed by the region `R0`.
crat... | (&self, pci: NllMemberConstraintIndex) -> &[ty::RegionVid] {
let NllMemberConstraint { start_index, end_index,.. } = &self.constraints[pci];
&self.choice_regions[*start_index..*end_index]
}
}
impl<'tcx, R> Index<NllMemberConstraintIndex> for MemberConstraintSet<'tcx, R>
where
R: Copy + Eq,
{
... | choice_regions | identifier_name |
mount.rs | use libc::{c_ulong, c_int};
use libc;
use {Errno, Result, NixPath};
bitflags!( | const MS_NOSUID = libc::MS_NOSUID; // Ignore suid and sgid bits
const MS_NODEV = libc::MS_NODEV; // Disallow access to device special files
const MS_NOEXEC = libc::MS_NOEXEC; // Disallow program execution
const MS_SYNCHRONOUS = libc::MS_SYNCHRONOUS; // Wri... | pub struct MsFlags: c_ulong {
const MS_RDONLY = libc::MS_RDONLY; // Mount read-only | random_line_split |
mount.rs | use libc::{c_ulong, c_int};
use libc;
use {Errno, Result, NixPath};
bitflags!(
pub struct MsFlags: c_ulong {
const MS_RDONLY = libc::MS_RDONLY; // Mount read-only
const MS_NOSUID = libc::MS_NOSUID; // Ignore suid and sgid bits
const MS_NODEV = libc::MS_NODEV; ... |
pub fn umount2<P:?Sized + NixPath>(target: &P, flags: MntFlags) -> Result<()> {
let res = try!(target.with_nix_path(|cstr| {
unsafe { libc::umount2(cstr.as_ptr(), flags.bits) }
}));
Errno::result(res).map(drop)
}
| {
let res = try!(target.with_nix_path(|cstr| {
unsafe { libc::umount(cstr.as_ptr()) }
}));
Errno::result(res).map(drop)
} | identifier_body |
mount.rs | use libc::{c_ulong, c_int};
use libc;
use {Errno, Result, NixPath};
bitflags!(
pub struct MsFlags: c_ulong {
const MS_RDONLY = libc::MS_RDONLY; // Mount read-only
const MS_NOSUID = libc::MS_NOSUID; // Ignore suid and sgid bits
const MS_NODEV = libc::MS_NODEV; ... | <P:?Sized + NixPath>(target: &P) -> Result<()> {
let res = try!(target.with_nix_path(|cstr| {
unsafe { libc::umount(cstr.as_ptr()) }
}));
Errno::result(res).map(drop)
}
pub fn umount2<P:?Sized + NixPath>(target: &P, flags: MntFlags) -> Result<()> {
let res = try!(target.with_nix_path(|cstr| {
... | umount | identifier_name |
mod.rs | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | {
Allow, Warn, Deny, Forbid
}
impl Level {
/// Convert a level to a lower-case string.
pub fn as_str(self) -> &'static str {
match self {
Allow => "allow",
Warn => "warn",
Deny => "deny",
Forbid => "forbid",
}
}
/// Convert a lower-c... | Level | identifier_name |
mod.rs | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... |
fn check_struct_field(&mut self, _: &Context, _: &ast::StructField) { }
fn check_variant(&mut self, _: &Context, _: &ast::Variant, _: &ast::Generics) { }
fn check_variant_post(&mut self, _: &Context, _: &ast::Variant, _: &ast::Generics) { }
fn check_opt_lifetime_ref(&mut self, _: &Context, _: Span, _: ... | { } | identifier_body |
mod.rs | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | );
}
/// Declare a static `LintArray` and return it as an expression.
#[macro_export]
macro_rules! lint_array { ($( $lint:expr ),*) => (
{
#[allow(non_upper_case_globals)]
static array: LintArray = &[ $( &$lint ),* ];
array
}
) }
pub type LintArray = &'static [&'static &'static Lin... | = &lint_initializer!($name, $level, $desc); | random_line_split |
window.rs | use std::collections::vec_deque::IntoIter as VecDequeIter;
use std::default::Default;
use Api;
use BuilderAttribs;
use ContextError;
use CreationError;
use CursorState;
use Event;
use GlContext;
use GlProfile;
use GlRequest;
use MouseCursor;
use PixelFormat;
use Robustness;
use native_monitor::NativeMonitorId;
use gl... | self.window.make_current()
}
/// Returns true if this context is the current one in this thread.
#[inline]
pub fn is_current(&self) -> bool {
self.window.is_current()
}
/// Returns the address of an OpenGL function.
///
/// Contrary to `wglGetProcAddress`, all available... | pub unsafe fn make_current(&self) -> Result<(), ContextError> { | random_line_split |
window.rs | use std::collections::vec_deque::IntoIter as VecDequeIter;
use std::default::Default;
use Api;
use BuilderAttribs;
use ContextError;
use CreationError;
use CursorState;
use Event;
use GlContext;
use GlProfile;
use GlRequest;
use MouseCursor;
use PixelFormat;
use Robustness;
use native_monitor::NativeMonitorId;
use gl... |
// default dimensions
if self.attribs.dimensions.is_none() {
self.attribs.dimensions = Some((1024, 768));
}
// building
platform::Window::new(self.attribs).map(|w| Window { window: w })
}
/// Builds the window.
///
/// The context is build in a *st... | {
self.attribs.dimensions = Some(self.attribs.monitor.as_ref().unwrap().get_dimensions())
} | conditional_block |
window.rs | use std::collections::vec_deque::IntoIter as VecDequeIter;
use std::default::Default;
use Api;
use BuilderAttribs;
use ContextError;
use CreationError;
use CursorState;
use Event;
use GlContext;
use GlProfile;
use GlRequest;
use MouseCursor;
use PixelFormat;
use Robustness;
use native_monitor::NativeMonitorId;
use gl... |
}
/// An iterator for the `poll_events` function.
pub struct PollEventsIterator<'a>(platform::PollEventsIterator<'a>);
impl<'a> Iterator for PollEventsIterator<'a> {
type Item = Event;
fn next(&mut self) -> Option<Event> {
self.0.next()
}
fn size_hint(&self) -> (usize, Option<usize>) {
... | {
self.proxy.wakeup_event_loop();
} | identifier_body |
window.rs | use std::collections::vec_deque::IntoIter as VecDequeIter;
use std::default::Default;
use Api;
use BuilderAttribs;
use ContextError;
use CreationError;
use CursorState;
use Event;
use GlContext;
use GlProfile;
use GlRequest;
use MouseCursor;
use PixelFormat;
use Robustness;
use native_monitor::NativeMonitorId;
use gl... | (mut self, title: String) -> WindowBuilder<'a> {
self.attribs.title = title;
self
}
/// Requests fullscreen mode.
///
/// If you don't specify dimensions for the window, it will match the monitor's.
pub fn with_fullscreen(mut self, monitor: MonitorID) -> WindowBuilder<'a> {
... | with_title | identifier_name |
as_bytes.rs | // Copyright 2016 blake2-rfc Developers
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according... |
unsafe impl Safe for u8 {}
unsafe impl Safe for u16 {}
unsafe impl Safe for u32 {}
unsafe impl Safe for u64 {}
unsafe impl Safe for i8 {}
unsafe impl Safe for i16 {}
unsafe impl Safe for i32 {}
unsafe impl Safe for i64 {} | } | random_line_split |
as_bytes.rs | // Copyright 2016 blake2-rfc Developers
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according... |
#[inline]
fn as_mut_bytes(&mut self) -> &mut [u8] {
unsafe {
slice::from_raw_parts_mut(self.as_mut_ptr() as *mut u8,
self.len() * mem::size_of::<T>())
}
}
}
unsafe impl Safe for u8 {}
unsafe impl Safe for u16 {}
unsafe impl Safe for u32 {}... | {
unsafe {
slice::from_raw_parts(self.as_ptr() as *const u8,
self.len() * mem::size_of::<T>())
}
} | identifier_body |
as_bytes.rs | // Copyright 2016 blake2-rfc Developers
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according... | (&mut self) -> &mut [u8] {
unsafe {
slice::from_raw_parts_mut(self.as_mut_ptr() as *mut u8,
self.len() * mem::size_of::<T>())
}
}
}
unsafe impl Safe for u8 {}
unsafe impl Safe for u16 {}
unsafe impl Safe for u32 {}
unsafe impl Safe for u64 {}
unsafe... | as_mut_bytes | identifier_name |
problem.rs | struct Container(i32, i32);
// A trait which checks if 2 items are stored inside of container.
// Also retrieves first or last value.
trait Contains<A, B> {
fn contains(&self, &A, &B) -> bool; // Explicitly requires `A` and `B`.
fn first(&self) -> i32; // Doesn't explicitly require `A` or `B`.
fn last(&sel... | (&self) -> i32 { self.1 }
}
// `C` contains `A` and `B`. In light of that, having to express `A` and
// `B` again is a nuisance.
fn difference<A, B, C>(container: &C) -> i32 where
C: Contains<A, B> {
container.last() - container.first()
}
fn main() {
let number_1 = 3;
let number_2 = 10;
let conta... | last | identifier_name |
problem.rs | struct Container(i32, i32);
// A trait which checks if 2 items are stored inside of container.
// Also retrieves first or last value.
trait Contains<A, B> {
fn contains(&self, &A, &B) -> bool; // Explicitly requires `A` and `B`.
fn first(&self) -> i32; // Doesn't explicitly require `A` or `B`.
fn last(&sel... |
fn main() {
let number_1 = 3;
let number_2 = 10;
let container = Container(number_1, number_2);
println!("Does container contain {} and {}: {}",
&number_1, &number_2,
container.contains(&number_1, &number_2));
println!("First number: {}", container.first());
println!("Last nu... | {
container.last() - container.first()
} | identifier_body |
problem.rs | struct Container(i32, i32);
// A trait which checks if 2 items are stored inside of container.
// Also retrieves first or last value.
trait Contains<A, B> { | }
impl Contains<i32, i32> for Container {
// True if the numbers stored are equal.
fn contains(&self, number_1: &i32, number_2: &i32) -> bool {
(&self.0 == number_1) && (&self.1 == number_2)
}
// Grab the first number.
fn first(&self) -> i32 { self.0 }
// Grab the last number.
fn ... | fn contains(&self, &A, &B) -> bool; // Explicitly requires `A` and `B`.
fn first(&self) -> i32; // Doesn't explicitly require `A` or `B`.
fn last(&self) -> i32; // Doesn't explicitly require `A` or `B`. | random_line_split |
schema.rs | table! {
__diesel_schema_migrations (version) {
version -> VarChar,
run_on -> Timestamp,
}
}
pub struct NewMigration<'a>(pub &'a str);
use backend::Backend;
use expression::AsExpression;
use expression::helper_types::AsExpr;
use persistable::{Insertable, ColumnInsertValue, InsertValues};
impl... | }
} | fn values(self) -> Self::Values {
(ColumnInsertValue::Expression(
__diesel_schema_migrations::version,
AsExpression::<::types::VarChar>::as_expression(self.0),
),) | random_line_split |
schema.rs | table! {
__diesel_schema_migrations (version) {
version -> VarChar,
run_on -> Timestamp,
}
}
pub struct | <'a>(pub &'a str);
use backend::Backend;
use expression::AsExpression;
use expression::helper_types::AsExpr;
use persistable::{Insertable, ColumnInsertValue, InsertValues};
impl<'update: 'a, 'a, DB> Insertable<__diesel_schema_migrations::table, DB>
for &'update NewMigration<'a> where
DB: Backend,
... | NewMigration | identifier_name |
autobind.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!(g(f), 1);
let f1: |Vec<String>| -> String = f;
assert_eq!(f1(vec!["x".to_string(), "y".to_string(), "z".to_string()]),
"x".to_string());
}
| { return act(vec!(1, 2, 3)); } | identifier_body |
autobind.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 http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn f<T>(x: Vec<T>)... | // | random_line_split |
autobind.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | <T>(x: Vec<T>) -> T { return x.into_iter().next().unwrap(); }
fn g(act: |Vec<int> | -> int) -> int { return act(vec!(1, 2, 3)); }
pub fn main() {
assert_eq!(g(f), 1);
let f1: |Vec<String>| -> String = f;
assert_eq!(f1(vec!["x".to_string(), "y".to_string(), "z".to_string()]),
"x".to_string()... | f | identifier_name |
suggestions.rs | #[cfg(feature = "suggestions")]
use strsim;
/// Produces a string from a given list of possible values which is similar to
/// the passed in value `v` with a certain confidence.
/// Thus in a list of possible values like ["foo", "bar"], the value "fop" will yield
/// `Some("foo")`, whereas "blark" would yield `None`.
... | <'a, T, I>(v: &str,
possible_values: I)
-> Option<&'a str>
where T: AsRef<str> + 'a,
I: IntoIterator<Item = &'a T>
{
let mut candidate: Option<(f64, &str)> = None;
for pv in possible_values.into_iter() {
let confidence = strsim:... | did_you_mean | identifier_name |
suggestions.rs | #[cfg(feature = "suggestions")]
use strsim;
/// Produces a string from a given list of possible values which is similar to
/// the passed in value `v` with a certain confidence.
/// Thus in a list of possible values like ["foo", "bar"], the value "fop" will yield
/// `Some("foo")`, whereas "blark" would yield `None`.
... | /// A helper to determine message formatting
pub enum DidYouMeanMessageStyle {
/// Suggested value is a long flag
LongFlag,
/// Suggested value is one of various possible values
EnumValue,
}
#[cfg(test)]
mod test {
use super::*;
#[test]
fn did_you_mean_possible_values() {
let p_val... | I: IntoIterator<Item = &'a T>
{
None
}
| random_line_split |
suggestions.rs | #[cfg(feature = "suggestions")]
use strsim;
/// Produces a string from a given list of possible values which is similar to
/// the passed in value `v` with a certain confidence.
/// Thus in a list of possible values like ["foo", "bar"], the value "fop" will yield
/// `Some("foo")`, whereas "blark" would yield `None`.
... |
#[cfg(not(feature = "suggestions"))]
pub fn did_you_mean<'a, T, I>(_: &str,
_: I)
-> Option<&'a str>
where T: AsRef<str> + 'a,
I: IntoIterator<Item = &'a T>
{
None
}
/// A helper to determine message formatting
pub enum DidYouMeanMessageS... | {
let mut candidate: Option<(f64, &str)> = None;
for pv in possible_values.into_iter() {
let confidence = strsim::jaro_winkler(v, pv.as_ref());
if confidence > 0.8 &&
(candidate.is_none() || (candidate.as_ref().unwrap().0 < confidence)) {
candidate = Some((confidence, pv.... | identifier_body |
workqueue.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 work queue for scheduling units of work across threads in a fork-join fashion.
//!
//! Data associated with ... |
/// Retrieves the index of the worker.
#[inline]
pub fn worker_index(&self) -> u8 {
self.worker_index
}
}
/// A work queue on which units of work can be submitted.
pub struct WorkQueue<QueueData:'static, WorkData:'static> {
/// Information about each of the workers.
workers: Vec<Worke... | {
self.queue_data
} | identifier_body |
workqueue.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 work queue for scheduling units of work across threads in a fork-join fashion.
//!
//! Data associated with ... | break
}
}
match self.other_deques[victim as usize].steal() {
Empty | Abort => {
// Continue.
}
... | loop {
victim = self.rng.next_u32() & deque_index_mask;
if (victim as usize) < self.other_deques.len() { | random_line_split |
workqueue.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 work queue for scheduling units of work across threads in a fork-join fashion.
//!
//! Data associated with ... | (mut v: u32) -> u32 {
v -= 1;
v |= v >> 1;
v |= v >> 2;
v |= v >> 4;
v |= v >> 8;
v |= v >> 16;
v += 1;
v
}
impl<QueueData: Sync, WorkData: Send> WorkerThread<QueueData, WorkData> {
/// The main logic. This function starts up the worker and listens for
/// messages.
fn start... | next_power_of_two | identifier_name |
mod.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 ... | (args: &[String]) {
let matches = match handle_options(Vec::from_slice(args)) {
Some(matches) => matches,
None => return
};
let descriptions = diagnostics::registry::Registry::new(super::DIAGNOSTICS);
match matches.opt_str("explain") {
Some(ref code) => {
match descr... | run_compiler | identifier_name |
mod.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 descriptions = diagnostics::registry::Registry::new(super::DIAGNOSTICS);
match matches.opt_str("explain") {
Some(ref code) => {
match descriptions.find_description(code.as_slice()) {
Some(ref description) => {
println!("{}", description);
... | let matches = match handle_options(Vec::from_slice(args)) {
Some(matches) => matches,
None => return
}; | random_line_split |
mod.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 ... |
}
return;
}
if print_crate_info(&sess, &input, &odir, &ofile) {
return;
}
driver::compile_input(sess, cfg, &input, &odir, &ofile, None);
}
/// Prints version information and returns None on success or an error
/// message on failure.
pub fn version(binary: &str, matches: &get... | {
early_error("can not list metadata for stdin");
} | conditional_block |
mod.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 usage() {
let message = format!("Usage: rustc [OPTIONS] INPUT");
println!("{}\n\
Additional help:
-C help Print codegen options
-W help Print 'lint' options and default settings
-Z help Print internal options for debugging rustc\n",
getopts::usa... | {
let verbose = match matches.opt_str("version").as_ref().map(|s| s.as_slice()) {
None => false,
Some("verbose") => true,
Some(s) => return Some(format!("Unrecognized argument: {}", s))
};
println!("{} {}", binary, env!("CFG_VERSION"));
if verbose {
println!("binary: {}"... | identifier_body |
combine_array_len.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 ... | }
fn main() {
assert_eq!(norm2([3.0, 4.0]), 5.0*5.0);
}
// END RUST SOURCE
// START rustc.norm2.InstCombine.before.mir
// _4 = Len(_1);
// ...
// _8 = Len(_1);
// END rustc.norm2.InstCombine.before.mir
// START rustc.norm2.InstCombine.after.mir
// _4 = const 2usize;
// ...
// _8 = const 2u... | fn norm2(x: [f32; 2]) -> f32 {
let a = x[0];
let b = x[1];
a*a + b*b | random_line_split |
combine_array_len.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 ... |
// END RUST SOURCE
// START rustc.norm2.InstCombine.before.mir
// _4 = Len(_1);
// ...
// _8 = Len(_1);
// END rustc.norm2.InstCombine.before.mir
// START rustc.norm2.InstCombine.after.mir
// _4 = const 2usize;
// ...
// _8 = const 2usize;
// END rustc.norm2.InstCombine.after.mir
| {
assert_eq!(norm2([3.0, 4.0]), 5.0*5.0);
} | identifier_body |
combine_array_len.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 ... | () {
assert_eq!(norm2([3.0, 4.0]), 5.0*5.0);
}
// END RUST SOURCE
// START rustc.norm2.InstCombine.before.mir
// _4 = Len(_1);
// ...
// _8 = Len(_1);
// END rustc.norm2.InstCombine.before.mir
// START rustc.norm2.InstCombine.after.mir
// _4 = const 2usize;
// ...
// _8 = const 2usize;
// E... | main | identifier_name |
pattern_type_mismatch.rs | use clippy_utils::diagnostics::span_lint_and_help;
use clippy_utils::last_path_segment;
use rustc_hir::{
intravisit, Body, Expr, ExprKind, FnDecl, HirId, LocalSource, MatchSource, Mutability, Pat, PatField, PatKind,
QPath, Stmt, StmtKind,
};
use rustc_lint::{LateContext, LateLintPass, LintContext};
use rustc_mi... | <'tcx>(
cx: &LateContext<'tcx>,
field_pats: &[PatField<'_>],
field_defs: &[FieldDef],
substs_ref: SubstsRef<'tcx>,
) -> Option<(Span, Mutability, Level)> {
for field_pat in field_pats {
'definitions: for field_def in field_defs {
if field_pat.ident == field_def.ident {
... | find_first_mismatch_in_struct | identifier_name |
pattern_type_mismatch.rs | use clippy_utils::diagnostics::span_lint_and_help;
use clippy_utils::last_path_segment;
use rustc_hir::{
intravisit, Body, Expr, ExprKind, FnDecl, HirId, LocalSource, MatchSource, Mutability, Pat, PatField, PatKind,
QPath, Stmt, StmtKind,
};
use rustc_lint::{LateContext, LateLintPass, LintContext};
use rustc_mi... | if let TyKind::Tuple(..) = ty.kind() {
return find_first_mismatch_in_tuple(cx, pats, ty.tuple_fields());
}
}
if let PatKind::Or(sub_pats) = pat.kind {
for pat in sub_pats {
let maybe_mismatch = find_first_mismatch(cx, pat, ty, level);
if let Some(mism... | random_line_split | |
pattern_type_mismatch.rs | use clippy_utils::diagnostics::span_lint_and_help;
use clippy_utils::last_path_segment;
use rustc_hir::{
intravisit, Body, Expr, ExprKind, FnDecl, HirId, LocalSource, MatchSource, Mutability, Pat, PatField, PatKind,
QPath, Stmt, StmtKind,
};
use rustc_lint::{LateContext, LateLintPass, LintContext};
use rustc_mi... | );
true
} else {
false
}
}
#[derive(Debug, Copy, Clone)]
enum Level {
Top,
Lower,
}
#[allow(rustc::usage_of_ty_tykind)]
fn find_first_mismatch<'tcx>(
cx: &LateContext<'tcx>,
pat: &Pat<'_>,
ty: Ty<'tcx>,
level: Level,
) -> Option<(Span, Mutability, Level)> {
... | {
let maybe_mismatch = find_first_mismatch(cx, pat, expr_ty, Level::Top);
if let Some((span, mutability, level)) = maybe_mismatch {
span_lint_and_help(
cx,
PATTERN_TYPE_MISMATCH,
span,
"type of pattern does not match the expression type",
None,... | identifier_body |
pattern_type_mismatch.rs | use clippy_utils::diagnostics::span_lint_and_help;
use clippy_utils::last_path_segment;
use rustc_hir::{
intravisit, Body, Expr, ExprKind, FnDecl, HirId, LocalSource, MatchSource, Mutability, Pat, PatField, PatKind,
QPath, Stmt, StmtKind,
};
use rustc_lint::{LateContext, LateLintPass, LintContext};
use rustc_mi... |
}
None
}
fn find_first_mismatch_in_struct<'tcx>(
cx: &LateContext<'tcx>,
field_pats: &[PatField<'_>],
field_defs: &[FieldDef],
substs_ref: SubstsRef<'tcx>,
) -> Option<(Span, Mutability, Level)> {
for field_pat in field_pats {
'definitions: for field_def in field_defs {
... | {
return Some(mismatch);
} | conditional_block |
mod.rs | /// Type definitions and serializations of types used in the VM and in other modules
#[derive(Serialize, Deserialize, Clone)]
pub struct Instruction {
pub opcode: Opcode,
pub target: Register,
pub left: Register,
pub right: Register
}
#[derive(Serialize, Deserialize)]
pub struct Module {
pub funct... | <'a> {
pub functions: &'a [u64],
pub constants: &'a [i64],
pub code: &'a [Instruction],
pub registers: &'a mut [i64],
pub base: usize
}
/// Definition of the register type and a list of special registers
pub type Register = u8;
pub mod reg {
use super::*;
pub const RET: Register = 0;
pu... | Thread | identifier_name |
mod.rs | /// Type definitions and serializations of types used in the VM and in other modules
#[derive(Serialize, Deserialize, Clone)]
pub struct Instruction {
pub opcode: Opcode,
pub target: Register,
pub left: Register,
pub right: Register
}
#[derive(Serialize, Deserialize)]
pub struct Module {
pub funct... | } | random_line_split | |
panic_in_result_fn_assertions.rs | #![warn(clippy::panic_in_result_fn)]
#![allow(clippy::unnecessary_wraps)]
struct A;
impl A {
fn result_with_assert_with_message(x: i32) -> Result<bool, String> // should emit lint
{
assert!(x == 5, "wrong argument");
Ok(true)
}
fn result_with_assert_eq(x: i32) -> Result<bool, String> ... | assert!(x == 5, "wrong argument");
}
fn other_with_assert_eq(x: i32) // should not emit lint
{
assert_eq!(x, 5);
}
fn other_with_assert_ne(x: i32) // should not emit lint
{
assert_ne!(x, 1);
}
fn result_without_banned_functions() -> Result<bool, String> // shou... | { | random_line_split |
panic_in_result_fn_assertions.rs | #![warn(clippy::panic_in_result_fn)]
#![allow(clippy::unnecessary_wraps)]
struct A;
impl A {
fn result_with_assert_with_message(x: i32) -> Result<bool, String> // should emit lint
{
assert!(x == 5, "wrong argument");
Ok(true)
}
fn result_with_assert_eq(x: i32) -> Result<bool, String> ... |
fn result_with_assert_ne(x: i32) -> Result<bool, String> // should emit lint
{
assert_ne!(x, 1);
Ok(true)
}
fn other_with_assert_with_message(x: i32) // should not emit lint
{
assert!(x == 5, "wrong argument");
}
fn other_with_assert_eq(x: i32) // should not emit ... | {
assert_eq!(x, 5);
Ok(true)
} | identifier_body |
panic_in_result_fn_assertions.rs | #![warn(clippy::panic_in_result_fn)]
#![allow(clippy::unnecessary_wraps)]
struct A;
impl A {
fn result_with_assert_with_message(x: i32) -> Result<bool, String> // should emit lint
{
assert!(x == 5, "wrong argument");
Ok(true)
}
fn | (x: i32) -> Result<bool, String> // should emit lint
{
assert_eq!(x, 5);
Ok(true)
}
fn result_with_assert_ne(x: i32) -> Result<bool, String> // should emit lint
{
assert_ne!(x, 1);
Ok(true)
}
fn other_with_assert_with_message(x: i32) // should not emit lint
... | result_with_assert_eq | identifier_name |
particle.rs | struct Particle {
x: f32,
y: f32,
dx: f32,
dy: f32,
frames_left: i32
}
impl Particle {
fn animate(&mut self) {
if self.in_use() {
return; |
--frames_left;
x += dx;
y += dy;
}
fn in_use(&self) -> bool {
self.frames_left > 0
}
}
const POOL_SIZE: i32 = 1000;
struct ParticlePool {
particles: [Particle; POOL_SIZE]
}
impl ParticlePool {
fn create(&self, x: f32, y: f32, dx: f32, dy: f32, lifetime: i32) {
... | } | random_line_split |
particle.rs | struct Particle {
x: f32,
y: f32,
dx: f32,
dy: f32,
frames_left: i32
}
impl Particle {
fn animate(&mut self) {
if self.in_use() |
--frames_left;
x += dx;
y += dy;
}
fn in_use(&self) -> bool {
self.frames_left > 0
}
}
const POOL_SIZE: i32 = 1000;
struct ParticlePool {
particles: [Particle; POOL_SIZE]
}
impl ParticlePool {
fn create(&self, x: f32, y: f32, dx: f32, dy: f32, lifetime: i32) {
... | {
return;
} | conditional_block |
particle.rs | struct Particle {
x: f32,
y: f32,
dx: f32,
dy: f32,
frames_left: i32
}
impl Particle {
fn animate(&mut self) {
if self.in_use() {
return;
}
--frames_left;
x += dx;
y += dy;
}
fn | (&self) -> bool {
self.frames_left > 0
}
}
const POOL_SIZE: i32 = 1000;
struct ParticlePool {
particles: [Particle; POOL_SIZE]
}
impl ParticlePool {
fn create(&self, x: f32, y: f32, dx: f32, dy: f32, lifetime: i32) {
for i in 0..POOL_SIZE {
if!particles[i].in_use() {
... | in_use | identifier_name |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.