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
traffic.rs
use std::env; use tokio::runtime::Runtime; use hubcaps::traffic::TimeUnit; use hubcaps::{Credentials, Github, Result}; fn main() -> Result<()> { pretty_env_logger::init(); match env::var("GITHUB_TOKEN").ok() { Some(token) =>
let views = rt.block_on(github.repo(owner, repo).traffic().views(TimeUnit::Day))?; println!("{:#?}", views); println!("Clones per day"); let clones = rt.block_on(github.repo(owner, repo).traffic().clones(TimeUnit::Day))?; println!("{:#?}", clones); ...
{ let mut rt = Runtime::new()?; let github = Github::new( concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION")), Credentials::Token(token), )?; let owner = "softprops"; let repo = "hubcaps"; println!("Top ...
conditional_block
traffic.rs
use std::env; use tokio::runtime::Runtime; use hubcaps::traffic::TimeUnit; use hubcaps::{Credentials, Github, Result}; fn main() -> Result<()>
} println!("Views per day"); let views = rt.block_on(github.repo(owner, repo).traffic().views(TimeUnit::Day))?; println!("{:#?}", views); println!("Clones per day"); let clones = rt.block_on(github.repo(owner, repo).traffic().clones(TimeUnit::Day...
{ pretty_env_logger::init(); match env::var("GITHUB_TOKEN").ok() { Some(token) => { let mut rt = Runtime::new()?; let github = Github::new( concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION")), Credentials::Token(token), )?; ...
identifier_body
traffic.rs
use std::env; use tokio::runtime::Runtime; use hubcaps::traffic::TimeUnit; use hubcaps::{Credentials, Github, Result}; fn main() -> Result<()> { pretty_env_logger::init();
Credentials::Token(token), )?; let owner = "softprops"; let repo = "hubcaps"; println!("Top 10 referrers"); for referrer in rt.block_on(github.repo(owner, repo).traffic().referrers())? { println!("{:#?}", referrer) ...
match env::var("GITHUB_TOKEN").ok() { Some(token) => { let mut rt = Runtime::new()?; let github = Github::new( concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION")),
random_line_split
diagnostic.rs
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ use crate::Location; use std::error::Error; use std::fmt; use std::fmt::Write; pub type DiagnosticsResult<T> = Result<T, Vec<Diagn...
]), ]; let output = combined_result(input.into_iter()); assert_eq!( output.as_ref().unwrap_err()[0].message().to_string(), "err0" ); assert_eq!( output.as_ref().unwrap_err()[1].message().to_string(), "err1" ); ...
Err(vec![ Diagnostic::error("err1", Location::generated()), Diagnostic::error("err2", Location::generated()),
random_line_split
diagnostic.rs
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ use crate::Location; use std::error::Error; use std::fmt; use std::fmt::Write; pub type DiagnosticsResult<T> = Result<T, Vec<Diagn...
pub fn location(&self) -> Location { self.0.location } pub fn related_information(&self) -> &[DiagnosticRelatedInformation] { &self.0.related_information } pub fn print_without_source(&self) -> String { let mut result = String::new(); writeln!( result,...
{ &self.0.message }
identifier_body
diagnostic.rs
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ use crate::Location; use std::error::Error; use std::fmt; use std::fmt::Write; pub type DiagnosticsResult<T> = Result<T, Vec<Diagn...
} /// Convert a list of DiagnosticsResult<T> into a DiagnosticsResult<Vec<T>>. /// This is similar to Result::from_iter except that in the case of an error /// result, Result::from_iter returns the first error in the list. Whereas /// this function concatenates all the Vec<Diagnostic> into one flat list. pub fn combi...
{ Err(diagnostics) }
conditional_block
diagnostic.rs
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ use crate::Location; use std::error::Error; use std::fmt; use std::fmt::Write; pub type DiagnosticsResult<T> = Result<T, Vec<Diagn...
<T>(result: T, diagnostics: Vec<Diagnostic>) -> DiagnosticsResult<T> { if diagnostics.is_empty() { Ok(result) } else { Err(diagnostics) } } /// Convert a list of DiagnosticsResult<T> into a DiagnosticsResult<Vec<T>>. /// This is similar to Result::from_iter except that in the case of an err...
diagnostics_result
identifier_name
values.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/. */ //! Helper types and traits for the handling of CSS values. use app_units::Au; use cssparser::UnicodeRange; use s...
/// Whether value is valid for this allowed numeric type. #[inline] pub fn is_ok(&self, value: f32) -> bool { match *self { AllowedNumericType::All => true, AllowedNumericType::NonNegative => value >= 0., } } /// Clamp the ...
random_line_split
values.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/. */ //! Helper types and traits for the handling of CSS values. use app_units::Au; use cssparser::UnicodeRange; use s...
(&self, value: f32) -> bool { match *self { AllowedNumericType::All => true, AllowedNumericType::NonNegative => value >= 0., } } /// Clamp the value following the rules of this numeric type. #[inline] pub fn clamp(&self, val: Au) -...
is_ok
identifier_name
values.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/. */ //! Helper types and traits for the handling of CSS values. use app_units::Au; use cssparser::UnicodeRange; use s...
} /// Marker trait to automatically implement ToCss for Vec<T>. pub trait OneOrMoreCommaSeparated {} impl OneOrMoreCommaSeparated for UnicodeRange {} impl<T> ToCss for Vec<T> where T: ToCss + OneOrMoreCommaSeparated { fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { let mut iter = ...
{ let mut s = String::new(); self.to_css(&mut s).unwrap(); s }
identifier_body
orientable.rs
// This file is part of rgtk.
// it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // rgtk is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // ME...
// // rgtk is free software: you can redistribute it and/or modify
random_line_split
orientable.rs
// This file is part of rgtk. // // rgtk is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // rgtk is distributed in the hop...
}
{ unsafe { ffi::gtk_orientable_set_orientation(GTK_ORIENTABLE(self.get_widget()), orientation) } }
identifier_body
orientable.rs
// This file is part of rgtk. // // rgtk is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // rgtk is distributed in the hop...
(&mut self, orientation: Orientation) -> () { unsafe { ffi::gtk_orientable_set_orientation(GTK_ORIENTABLE(self.get_widget()), orientation) } } }
set_orientation
identifier_name
interrupts.rs
// "Tifflin" Kernel // - By John Hodge (thePowersGang) // // Core/main.rs //! Low-level interrupt handling and CPU error handling //use prelude::*; #[repr(C)] /// A handler for an ISR pub type ISRHandler = extern "C" fn(isrnum: usize,info:*const(),idx:usize); struct IRQHandlersEnt { handler: Option<ISRHandler>, inf...
{ idx: usize, } static S_IRQ_HANDLERS_LOCK: ::sync::Spinlock<[IRQHandlersEnt; 256]> = ::sync::Spinlock::new( [IRQHandlersEnt{ handler: None, info: 0 as *const _, idx: 0 }; 256] ); #[no_mangle] #[doc(hidden)] #[tag_safe(irq)] /// ISR handler called by assembly pub extern "C" fn irq_handler(index: usize) { let l...
ISRHandle
identifier_name
interrupts.rs
// "Tifflin" Kernel // - By John Hodge (thePowersGang) // // Core/main.rs //! Low-level interrupt handling and CPU error handling //use prelude::*; #[repr(C)] /// A handler for an ISR pub type ISRHandler = extern "C" fn(isrnum: usize,info:*const(),idx:usize); struct IRQHandlersEnt { handler: Option<ISRHandler>, inf...
}; return Ok( ISRHandle { idx: i, } ) } } Err( BindISRError::Used ) } impl ISRHandle { /// Returns an unbound ISR handle (null) pub fn unbound() -> ISRHandle { ISRHandle { idx:!0, } } /// Returns the bound ISR index pub fn idx(&self) -> usize { self.idx } } impl ::core::ops::Drop for ...
info: info, idx: idx,
random_line_split
interrupts.rs
// "Tifflin" Kernel // - By John Hodge (thePowersGang) // // Core/main.rs //! Low-level interrupt handling and CPU error handling //use prelude::*; #[repr(C)] /// A handler for an ISR pub type ISRHandler = extern "C" fn(isrnum: usize,info:*const(),idx:usize); struct IRQHandlersEnt { handler: Option<ISRHandler>, inf...
} } // vim: ft=rust
{ let _irq_hold = ::arch::sync::hold_interrupts(); let mut mh = S_IRQ_HANDLERS_LOCK.lock(); let h = &mut mh[self.idx]; h.handler = None; }
conditional_block
mod.rs
pub mod client_connection; pub mod client_session; pub mod local_router; pub mod router_follower; pub mod router_leader; pub mod session_timer; use std::fmt; use std::net::SocketAddr; use std::time::Instant; use mqtt::{QualityOfService}; use mqtt::packet::{PublishPacket, SubscribePacket, UnsubscribePacket}; use comm...
{ _Shutdown } #[derive(Debug, Copy, Clone)] pub enum SessionTimerAction { Set(Instant), Cancel } #[derive(Debug, Eq, PartialEq, Hash, Clone)] pub enum SessionTimerPacketType { // [QoS.1.send] Receive PUBACK timeout RecvPubackTimeout, // [QoS.2.send] Receive PUBREC timeout RecvPubrecTimeout, ...
RouterLeaderMsg
identifier_name
mod.rs
pub mod client_connection; pub mod client_session; pub mod local_router; pub mod router_follower; pub mod router_leader; pub mod session_timer; use std::fmt; use std::net::SocketAddr; use std::time::Instant; use mqtt::{QualityOfService}; use mqtt::packet::{PublishPacket, SubscribePacket, UnsubscribePacket}; use commo...
#[derive(Clone)] pub enum ClientSessionMsg { Data(SocketAddr, Vec<u8>), // (user_id, client_identifier, qos, packet) Publish(UserId, ClientIdentifier, QualityOfService, PublishPacket), ClientDisconnect(SocketAddr, String), // (user_id, addr, packets, subscribe_qos) RetainPackets(UserId, SocketAd...
// Shutdown }
random_line_split
syntax-extension-bytes.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ let vec = bytes!("abc"); assert_eq!(vec, &[97_u8, 98_u8, 99_u8]); let vec = bytes!("null", 0); assert_eq!(vec, &[110_u8, 117_u8, 108_u8, 108_u8, 0_u8]); let vec = bytes!(' ', " ", 32, 32u8); assert_eq!(vec, &[32_u8, 32_u8, 32_u8, 32_u8]); assert_eq!(static_vec, &[97_u8, 98_u8, 99_u8, 25...
identifier_body
syntax-extension-bytes.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 ...
}
random_line_split
syntax-extension-bytes.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { let vec = bytes!("abc"); assert_eq!(vec, &[97_u8, 98_u8, 99_u8]); let vec = bytes!("null", 0); assert_eq!(vec, &[110_u8, 117_u8, 108_u8, 108_u8, 0_u8]); let vec = bytes!(' ', " ", 32, 32u8); assert_eq!(vec, &[32_u8, 32_u8, 32_u8, 32_u8]); assert_eq!(static_vec, &[97_u8, 98_u8, 99_u8,...
main
identifier_name
lib.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 #![forbid(unsafe_code)] use crate::function_target_pipeline::FunctionTargetsHolder; use move_model::model::GlobalEnv; pub mod access_path; pub mod access_path_trie; pub mod annotations; pub mod borrow_analysis; pub mod clean_and_optim...
} } } text }
{ target.register_annotation_formatters_for_test(); text += &format!("\n[variant {}]\n{}\n", variant, target); }
conditional_block
lib.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 #![forbid(unsafe_code)] use crate::function_target_pipeline::FunctionTargetsHolder; use move_model::model::GlobalEnv; pub mod access_path; pub mod access_path_trie; pub mod annotations; pub mod borrow_analysis; pub mod clean_and_optim...
{ let mut text = String::new(); text.push_str(&format!("============ {} ================\n", header)); for module_env in env.get_modules() { for func_env in module_env.get_functions() { for (variant, target) in targets.get_targets(&func_env) { if !target.data.code.is_empt...
identifier_body
lib.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 #![forbid(unsafe_code)] use crate::function_target_pipeline::FunctionTargetsHolder; use move_model::model::GlobalEnv; pub mod access_path; pub mod access_path_trie; pub mod annotations; pub mod borrow_analysis; pub mod clean_and_optim...
( env: &GlobalEnv, header: &str, targets: &FunctionTargetsHolder, ) -> String { let mut text = String::new(); text.push_str(&format!("============ {} ================\n", header)); for module_env in env.get_modules() { for func_env in module_env.get_functions() { for (variant...
print_targets_for_test
identifier_name
lib.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 #![forbid(unsafe_code)] use crate::function_target_pipeline::FunctionTargetsHolder; use move_model::model::GlobalEnv;
pub mod clean_and_optimize; pub mod compositional_analysis; pub mod data_invariant_instrumentation; pub mod dataflow_analysis; pub mod debug_instrumentation; pub mod eliminate_imm_refs; pub mod function_data_builder; pub mod function_target; pub mod function_target_pipeline; pub mod global_invariant_instrumentation; pu...
pub mod access_path; pub mod access_path_trie; pub mod annotations; pub mod borrow_analysis;
random_line_split
strand.rs
/* * strand.rs * * striking-db - Persistent key/value store for SSDs. * Copyright (c) 2017 Maxwell Duzen, Ammon Smith * * striking-db is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation, either versi...
} impl<'d> Strand<'d> { pub fn new( device: &'d Device, id: u16, start: u64, capacity: u64, read_strand: bool, ) -> Result<Self> { assert_eq!( start % PAGE_SIZE64, 0, "Start is not a multiple of the page size" ); ...
capacity: u64, offset: u64, pub stats: Mutex<Stats>,
random_line_split
strand.rs
/* * strand.rs * * striking-db - Persistent key/value store for SSDs. * Copyright (c) 2017 Maxwell Duzen, Ammon Smith * * striking-db is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation, either versi...
#[inline] pub fn push_offset(&mut self, amt: u64) { self.offset += amt; } #[inline] pub fn contains_ptr(&self, ptr: FilePointer) -> bool { self.start <= ptr && ptr <= self.end() } pub fn write_metadata(&mut self) -> Result<()> { let mut page = Page::default(); ...
{ self.offset }
identifier_body
strand.rs
/* * strand.rs * * striking-db - Persistent key/value store for SSDs. * Copyright (c) 2017 Maxwell Duzen, Ammon Smith * * striking-db is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation, either versi...
(&mut self) { self.write_metadata().expect("Error writing metadata"); } }
drop
identifier_name
strand.rs
/* * strand.rs * * striking-db - Persistent key/value store for SSDs. * Copyright (c) 2017 Maxwell Duzen, Ammon Smith * * striking-db is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation, either versi...
}; Ok(Strand { device: device, id: id, start: start, capacity: capacity, offset: offset, stats: Mutex::new(Stats::default()), }) } #[inline] pub fn id(&self) -> u16 { self.id } #[inline] p...
{ // Format strand let header = StrandHeader::new(id, capacity); header.write(&mut page)?; device.write(0, &page[..])?; PAGE_SIZE64 }
conditional_block
transaction.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 crate::errors; use crate::statecallback::StateCallback; use crate::transport::platformmonitor::Monitor; use ru...
timeout, ) .map_err(|_| errors::AuthenticatorError::Platform)?; Ok(Self { thread: Some(thread), }) } pub fn cancel(&mut self) { // This must never be None. self.thread.take().unwrap().cancel(); } }
random_line_split
transaction.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 crate::errors; use crate::statecallback::StateCallback; use crate::transport::platformmonitor::Monitor; use ru...
(&mut self) { // This must never be None. self.thread.take().unwrap().cancel(); } }
cancel
identifier_name
prelude.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
//! The I/O Prelude //! //! The purpose of this module is to alleviate imports of many common I/O traits //! by adding a glob import to the top of I/O heavy modules: //! //! ``` //! # #![allow(unused_imports)] //! use std::io::prelude::*; //! ``` #![stable(feature = "rust1", since = "1.0.0")] pub use super::{Read, Wr...
random_line_split
main.rs
use std::io::{self, Read, Write}; use std::env; fn main() { let content_length = env::var("CONTENT_LENGTH").unwrap_or("0".into()) .parse::<u64>().expect("Error parsing CONTENT_LENGTH"); let status = match handle(content_length) { Ok(_) => 0, Err(_) => 1, }; ::std::process::exit(s...
(content_length: u64) -> io::Result<()> { let mut buffer = Vec::new(); io::stdin().take(content_length).read_to_end(&mut buffer)?; println!("Content-Type: text/html"); println!(); println!("<p>Hello, world!</p>"); println!("<ul>"); for (key, value) in ::std::env::vars() { println!("...
handle
identifier_name
main.rs
use std::io::{self, Read, Write}; use std::env; fn main() { let content_length = env::var("CONTENT_LENGTH").unwrap_or("0".into()) .parse::<u64>().expect("Error parsing CONTENT_LENGTH"); let status = match handle(content_length) { Ok(_) => 0, Err(_) => 1, }; ::std::process::exit(s...
println!("<ul>"); for (key, value) in ::std::env::vars() { println!("<li>{}: {}</li>", key, value); } println!("</ul>"); println!("<p>"); io::stdout().write(&buffer[..])?; println!("</p>"); Ok(()) }
println!(); println!("<p>Hello, world!</p>");
random_line_split
main.rs
use std::io::{self, Read, Write}; use std::env; fn main()
fn handle(content_length: u64) -> io::Result<()> { let mut buffer = Vec::new(); io::stdin().take(content_length).read_to_end(&mut buffer)?; println!("Content-Type: text/html"); println!(); println!("<p>Hello, world!</p>"); println!("<ul>"); for (key, value) in ::std::env::vars() { ...
{ let content_length = env::var("CONTENT_LENGTH").unwrap_or("0".into()) .parse::<u64>().expect("Error parsing CONTENT_LENGTH"); let status = match handle(content_length) { Ok(_) => 0, Err(_) => 1, }; ::std::process::exit(status); }
identifier_body
font.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/. */ extern mod freetype; use font::{FontHandleMethods, FontMetrics, FontTableMethods}; use font::{FontTableTag, Fract...
let mut face: FT_Face = ptr::null(); let face_index = 0 as FT_Long; file.to_c_str().with_ref(|file_str| { FT_New_Face(ft_ctx, file_str, face_index, ptr::to_mut_unsafe_ptr(&mut face)); }); if face.is_null() { ...
{ return Err(()); }
conditional_block
font.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/. */ extern mod freetype; use font::{FontHandleMethods, FontMetrics, FontTableMethods}; use font::{FontTableTag, Fract...
(&self) -> bool { unsafe { (*self.face).style_flags & FT_STYLE_FLAG_ITALIC!= 0 } } fn boldness(&self) -> font_weight::T { let default_weight = font_weight::Weight400; if unsafe { (*self.face).style_flags & FT_STYLE_FLAG_BOLD == 0 } { default_weight } else { ...
is_italic
identifier_name
font.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/. */ extern mod freetype; use font::{FontHandleMethods, FontMetrics, FontTableMethods}; use font::{FontTableTag, Fract...
float_to_fixed(6, f) } fn fixed_to_float_ft(f: i32) -> f64 { fixed_to_float(6, f) } pub struct FontTable { bogus: () } impl FontTableMethods for FontTable { fn with_buffer(&self, _blk: |*u8, uint|) { fail!() } } enum FontSource { FontSourceMem(~[u8]), FontSourceFile(~str) } pub ...
use std::ptr; use std::str; fn float_to_fixed_ft(f: f64) -> i32 {
random_line_split
font.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/. */ extern mod freetype; use font::{FontHandleMethods, FontMetrics, FontTableMethods}; use font::{FontTableTag, Fract...
fn glyph_index(&self, codepoint: char) -> Option<GlyphIndex> { assert!(self.face.is_not_null()); unsafe { let idx = FT_Get_Char_Index(self.face, codepoint as FT_ULong); return if idx!= 0 as FT_UInt { Some(idx as GlyphIndex) ...
{ match self.source { FontSourceMem(ref buf) => { FontHandleMethods::new_from_buffer(fctx, buf.clone(), style) } FontSourceFile(ref file) => { FontHandle::new_from_file(fctx, (*file).clone(), style) } } }
identifier_body
imag_category.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...
(tempdir: &TempDir) -> Command { crate::imag::binary(tempdir, "imag-category") } pub fn call(tmpdir: &TempDir, args: &[&str]) -> Vec<String> { let mut binary = binary(tmpdir); binary.stdin(std::process::Stdio::inherit()); binary.arg("--pipe-input"); binary.arg("--pipe-output"); binary.args(args...
binary
identifier_name
imag_category.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...
use std::process::Command; use assert_fs::fixture::TempDir; pub fn binary(tempdir: &TempDir) -> Command { crate::imag::binary(tempdir, "imag-category") } pub fn call(tmpdir: &TempDir, args: &[&str]) -> Vec<String> { let mut binary = binary(tmpdir); binary.stdin(std::process::Stdio::inherit()); binar...
random_line_split
imag_category.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...
#[test] fn test_new_entry_has_no_category() { crate::setup_logging(); let imag_home = crate::imag::make_temphome(); crate::imag_init::call(&imag_home); crate::imag_create::call(&imag_home, &["test"]); let (assert, stderr_output) = { let mut binary = binary(&imag_home); binary.stdi...
{ let mut binary = binary(tmpdir); binary.stdin(std::process::Stdio::inherit()); binary.arg("--pipe-input"); binary.arg("--pipe-output"); binary.args(args); debug!("Command = {:?}", binary); crate::imag::stdout_of_command(binary) }
identifier_body
non-exhaustive-pattern-witness.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 ...
() { match ((), false) { //~^ ERROR non-exhaustive patterns: `((), false)` not covered ((), true) => () } } fn main() {}
missing_nil
identifier_name
non-exhaustive-pattern-witness.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 ...
[Enum::Second(true), Enum::First] => (), [Enum::Second(true), Enum::Second(true)] => (), [Enum::Second(false), _] => (), [_, _, tail.., _] => () } } fn missing_nil() { match ((), false) { //~^ ERROR non-exhaustive patterns: `((), false)` not covered ((), true) => () ...
[_] => (), [Enum::First, _] => (),
random_line_split
main.rs
#![feature(macro_rules)] #![feature(globs)] #![feature(phase)] #![allow(missing_copy_implementations)] #[phase(plugin)] extern crate gl_generator; extern crate glfw; extern crate time; use glfw::{Glfw, Context, OpenGlProfileHint, WindowHint, WindowMode}; use std::rand::{task_rng, Rng}; use std::num::FloatMath; us...
particle.color.blue += particle.fade / 3.0; } // Replace dead particles for i in range(0u, particles.len()) { if particles[i].life < 0.05 { particles.remove(i); particles.insert(i, create_new_particle()); } } // Add new particles if missing let m...
particle.yi *= 0.999; particle.color.alpha = 1.0 * particle.life / MAX_LIFE; particle.color.red += particle.fade / 3.0; particle.color.green += particle.fade / 3.0;
random_line_split
main.rs
#![feature(macro_rules)] #![feature(globs)] #![feature(phase)] #![allow(missing_copy_implementations)] #[phase(plugin)] extern crate gl_generator; extern crate glfw; extern crate time; use glfw::{Glfw, Context, OpenGlProfileHint, WindowHint, WindowMode}; use std::rand::{task_rng, Rng}; use std::num::FloatMath; us...
} } // Add new particles if missing let mut i = 0i; loop { if particles.len() < MAX_PARTICLES { particles.push(create_new_particle()); i += 1 ; } else { break; } if i > 20 { break; } } }
{ // Move & decay existing particles for mut particle in particles.iter_mut() { particle.life -= particle.fade; particle.x += particle.xi; particle.y += particle.yi; particle.xi *= 0.999; particle.yi *= 0.999; particle.color.alpha = 1.0 * particle.life / MAX_LIFE...
identifier_body
main.rs
#![feature(macro_rules)] #![feature(globs)] #![feature(phase)] #![allow(missing_copy_implementations)] #[phase(plugin)] extern crate gl_generator; extern crate glfw; extern crate time; use glfw::{Glfw, Context, OpenGlProfileHint, WindowHint, WindowMode}; use std::rand::{task_rng, Rng}; use std::num::FloatMath; us...
{ red: f32, green: f32, blue: f32, alpha: f32 } struct Particle { life: f32, fade: f32, x: f32, y: f32, xi: f32, yi: f32, color: Color } static WINDOW_WIDTH: u32 = 800; static WINDOW_HEIGHT: u32 = 600; static MAX_PARTICLES: uint = 20000; static MAX_LIFE: f32 = 2.5; static...
Color
identifier_name
main.rs
#![feature(macro_rules)] #![feature(globs)] #![feature(phase)] #![allow(missing_copy_implementations)] #[phase(plugin)] extern crate gl_generator; extern crate glfw; extern crate time; use glfw::{Glfw, Context, OpenGlProfileHint, WindowHint, WindowMode}; use std::rand::{task_rng, Rng}; use std::num::FloatMath; us...
if i > 20 { break; } } }
{ break; }
conditional_block
cli.rs
use structopt::StructOpt; #[derive(StructOpt)] #[structopt( name = "blog", after_help = "You can also run `blog SUBCOMMAND -h` to get more information about that subcommand." )] pub enum Cli { /// Create a new wonderfully delighting blog post #[structopt(name = "create_post")] CreatePost { ...
Register, }
random_line_split
cli.rs
use structopt::StructOpt; #[derive(StructOpt)] #[structopt( name = "blog", after_help = "You can also run `blog SUBCOMMAND -h` to get more information about that subcommand." )] pub enum
{ /// Create a new wonderfully delighting blog post #[structopt(name = "create_post")] CreatePost { /// The title of your post #[structopt(long = "title")] title: String, }, /// Fine-tune an existing post to reach 100% reader delight #[structopt(name = "edit_post")] ...
Cli
identifier_name
lib.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/. */ #![feature(box_syntax)] #![feature(custom_derive)] #![feature(box_raw)] #![feature(plugin)] #![feature(slice_patte...
/// Data for passing between threads/processes to indicate a particular action to /// take on a provided network listener. #[derive(Deserialize, Serialize)] pub enum ResponseAction { /// Invoke headers_available HeadersAvailable(Metadata), /// Invoke data_available DataAvailable(Vec<u8>), /// Invoke...
/// The response is complete. If the provided status is an Err value, there is no guarantee /// that the response body was completely read. fn response_complete(&self, status: Result<(), String>); }
random_line_split
lib.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/. */ #![feature(box_syntax)] #![feature(custom_derive)] #![feature(box_raw)] #![feature(plugin)] #![feature(slice_patte...
(&mut self) -> Option<Vec<u8>> { match self.progress_port.recv().unwrap() { ProgressMsg::Payload(data) => Some(data), ProgressMsg::Done(Ok(())) => None, ProgressMsg::Done(Err(e)) => { error!("error receiving bytes: {}", e); None }...
next
identifier_name
link.rs
#![crate_name = "link"] /* * This file is part of the uutils coreutils package. * * (c) Michael Gehring <mg@ebfe.org> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ extern crate getopts; #[macro_use] extern crate uucore; use s...
#[allow(dead_code)] fn main() { std::process::exit(uumain(std::env::args().collect())); }
} }
random_line_split
link.rs
#![crate_name = "link"] /* * This file is part of the uutils coreutils package. * * (c) Michael Gehring <mg@ebfe.org> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ extern crate getopts; #[macro_use] extern crate uucore; use s...
if matches.opt_present("help") || matches.free.len()!= 2 { let msg = format!("{0} {1} Usage: {0} [OPTIONS] FILE1 FILE2 Create a link named FILE2 to FILE1.", NAME, VERSION); println!("{}", opts.usage(&msg)); if matches.free.len()!= 2 { return 1; } return 0; ...
{ println!("{} {}", NAME, VERSION); return 0; }
conditional_block
link.rs
#![crate_name = "link"] /* * This file is part of the uutils coreutils package. * * (c) Michael Gehring <mg@ebfe.org> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ extern crate getopts; #[macro_use] extern crate uucore; use s...
(args: Vec<String>) -> i32 { let mut opts = getopts::Options::new(); opts.optflag("h", "help", "display this help and exit"); opts.optflag("V", "version", "output version information and exit"); let matches = match opts.parse(&args[1..]) { Ok(m) => m, Err(err) => panic!("{}", err), ...
uumain
identifier_name
link.rs
#![crate_name = "link"] /* * This file is part of the uutils coreutils package. * * (c) Michael Gehring <mg@ebfe.org> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ extern crate getopts; #[macro_use] extern crate uucore; use s...
{0} [OPTIONS] FILE1 FILE2 Create a link named FILE2 to FILE1.", NAME, VERSION); println!("{}", opts.usage(&msg)); if matches.free.len()!= 2 { return 1; } return 0; } let old = Path::new(&matches.free[0]); let new = Path::new(&matches.free[1]); match hard...
{ let mut opts = getopts::Options::new(); opts.optflag("h", "help", "display this help and exit"); opts.optflag("V", "version", "output version information and exit"); let matches = match opts.parse(&args[1..]) { Ok(m) => m, Err(err) => panic!("{}", err), }; if matches.opt_pre...
identifier_body
issue-14959.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 ...
} } impl<'a, 'b> Fn<(&'b mut Response+'b,),()> for SendFile<'a> { extern "rust-call" fn call(&self, (_res,): (&'b mut Response+'b,)) {} } impl<Rq: Request, Rs: Response> Ingot<Rq, Rs> for HelloWorld { fn enter(&mut self, _req: &mut Rq, res: &mut Rs, alloy: &mut Alloy) -> Status { let send_file = a...
impl Alloy { fn find<T>(&self) -> Option<T> { None
random_line_split
issue-14959.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 send_file = alloy.find::<SendFile>().unwrap(); send_file(res); Status::Continue }
identifier_body
issue-14959.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 ...
() {}
main
identifier_name
net.rs
use super::abi; use crate::{ cmp, ffi::CStr, io::{self, ErrorKind, IoSlice, IoSliceMut}, mem, net::{Shutdown, SocketAddr}, ptr, str, sys_common::net::{getsockopt, setsockopt, sockaddr_to_addr}, sys_common::{AsInner, FromInner, IntoInner}, time::Duration, }; use self::netc::{sockaddr...
/// Just to provide the same interface as sys/unix/net.rs pub fn cvt_r<T, F>(mut f: F) -> io::Result<T> where T: IsMinusOne, F: FnMut() -> T, { cvt(f()) } /// Returns the last error from the network subsystem. fn last_error() -> io::Error { io::Error::from_raw_os_error(unsafe { netc::SOLID_NET_GetLas...
{ if err == 0 { Ok(()) } else { let msg: &dyn crate::fmt::Display = match err { netc::EAI_NONAME => &"name or service not known", netc::EAI_SERVICE => &"service not supported", netc::EAI_FAIL => &"non-recoverable failure in name resolution", netc::...
identifier_body
net.rs
use super::abi; use crate::{ cmp, ffi::CStr, io::{self, ErrorKind, IoSlice, IoSliceMut}, mem, net::{Shutdown, SocketAddr}, ptr, str, sys_common::net::{getsockopt, setsockopt, sockaddr_to_addr}, sys_common::{AsInner, FromInner, IntoInner}, time::Duration, }; use self::netc::{sockaddr...
F: FnMut() -> T, { cvt(f()) } /// Returns the last error from the network subsystem. fn last_error() -> io::Error { io::Error::from_raw_os_error(unsafe { netc::SOLID_NET_GetLastError() }) } pub(super) fn error_name(er: abi::ER) -> Option<&'static str> { unsafe { CStr::from_ptr(netc::strerror(er)) }.to...
/// Just to provide the same interface as sys/unix/net.rs pub fn cvt_r<T, F>(mut f: F) -> io::Result<T> where T: IsMinusOne,
random_line_split
net.rs
use super::abi; use crate::{ cmp, ffi::CStr, io::{self, ErrorKind, IoSlice, IoSliceMut}, mem, net::{Shutdown, SocketAddr}, ptr, str, sys_common::net::{getsockopt, setsockopt, sockaddr_to_addr}, sys_common::{AsInner, FromInner, IntoInner}, time::Duration, }; use self::netc::{sockaddr...
(&self, kind: c_int) -> io::Result<Option<Duration>> { let raw: netc::timeval = getsockopt(self, netc::SOL_SOCKET, kind)?; if raw.tv_sec == 0 && raw.tv_usec == 0 { Ok(None) } else { let sec = raw.tv_sec as u64; let nsec = (raw.tv_usec as u32) * 1000; ...
timeout
identifier_name
color.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/. */ //! Specified color values. use super::AllowQuirks; #[cfg(feature = "gecko")] use crate::gecko_bindings::structs...
_context.map(|context| ComputedColor::rgba(context.device().body_text_color())) }, } } } impl ToComputedValue for Color { type ComputedValue = ComputedColor; fn to_computed_value(&self, context: &Context) -> ComputedColor { let result = self.to_computed_color(So...
random_line_split
color.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/. */ //! Specified color values. use super::AllowQuirks; #[cfg(feature = "gecko")] use crate::gecko_bindings::structs...
} /// A wrapper of cssparser::Color::parse_hash. /// /// That function should never return CurrentColor, so it makes no sense to /// handle a cssparser::Color here. This should really be done in cssparser /// directly rather than here. fn parse_hash_color(value: &[u8]) -> Result<RGBA, ()> { CSSParserColor::parse_...
{ match *self { Color::CurrentColor => CSSParserColor::CurrentColor.to_css(dest), Color::Numeric { authored: Some(ref authored), .. } => dest.write_str(authored), Color::Numeric { parsed: ref rgba, .. } =...
identifier_body
color.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/. */ //! Specified color values. use super::AllowQuirks; #[cfg(feature = "gecko")] use crate::gecko_bindings::structs...
<'i, 't>( context: &ParserContext, input: &mut Parser<'i, 't>, allow_quirks: AllowQuirks, ) -> Result<Self, ParseError<'i>> { input.try(|i| Self::parse(context, i)).or_else(|e| { if!allow_quirks.allowed(context.quirks_mode) { return Err(e); } ...
parse_quirky
identifier_name
color.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/. */ //! Specified color values. use super::AllowQuirks; #[cfg(feature = "gecko")] use crate::gecko_bindings::structs...
else if value <= 99 { 2 } else if value <= 999 { 3 } else if value <= 9999 { 4 } else if value <= 99999 { 5 } else if value <= 999999 { 6 } else { return Err(location.new_custom_error(StyleParseErrorKind::Un...
{ 1 }
conditional_block
sort.rs
#![deny(warnings)] extern crate coreutils; extern crate extra; use std::env; use std::io::{stdout, stderr, stdin, Error, Write, BufRead, BufReader}; use std::process::exit; use std::cmp::Ordering; use coreutils::ArgParser; use std::fs::File; use extra::option::OptionalExt; const MAN_PAGE: &'static str = r#" NAME ...
fn lines_from_files(paths: &Vec<&String>) -> Result<Vec<String>, Error> { let mut lines = Vec::new(); for path in paths { let f = try!(File::open(path)); let f = BufReader::new(f); for line in f.lines() { match line { Ok(l) => lines.push(l), ...
{ let stdin = stdin(); let mut lines = Vec::new(); let f = BufReader::new(stdin.lock()); for line in f.lines() { match line { Ok(l) => lines.push(l), Err(e) => return Err(e), } } Ok(lines) }
identifier_body
sort.rs
#![deny(warnings)] extern crate coreutils; extern crate extra; use std::env; use std::io::{stdout, stderr, stdin, Error, Write, BufRead, BufReader}; use std::process::exit; use std::cmp::Ordering; use coreutils::ArgParser; use std::fs::File; use extra::option::OptionalExt; const MAN_PAGE: &'static str = r#" NAME ...
() { let stdout = stdout(); let mut stdout = stdout.lock(); let mut stderr = stderr(); let mut parser = ArgParser::new(2) .add_flag(&["n", "numeric-sort"]) .add_flag(&["u", "unique"]) .add_flag(&["h", "help"]); parser.parse(env::args()); if parser.found("help") { s...
main
identifier_name
sort.rs
#![deny(warnings)] extern crate coreutils; extern crate extra; use std::env; use std::io::{stdout, stderr, stdin, Error, Write, BufRead, BufReader}; use std::process::exit; use std::cmp::Ordering; use coreutils::ArgParser; use std::fs::File; use extra::option::OptionalExt; const MAN_PAGE: &'static str = r#" NAME ...
} if parser.found("unique") { l.dedup(); } for x in l { println!("{}", x); } } Err(e) => { let _ = write!(stderr, "{}", e); } } }
l.sort_by(numeric_compare); } else { l.sort();
random_line_split
sort.rs
#![deny(warnings)] extern crate coreutils; extern crate extra; use std::env; use std::io::{stdout, stderr, stdin, Error, Write, BufRead, BufReader}; use std::process::exit; use std::cmp::Ordering; use coreutils::ArgParser; use std::fs::File; use extra::option::OptionalExt; const MAN_PAGE: &'static str = r#" NAME ...
let lines = match parser.args.is_empty() { true => lines_from_stdin(), false => { let mut paths = Vec::new(); for dir in parser.args.iter() { paths.push(dir); } lines_from_files(&paths) } }; match lines { Ok(m...
{ stdout.write(MAN_PAGE.as_bytes()).try(&mut stderr); stdout.flush().try(&mut stderr); exit(0); }
conditional_block
lib.rs
extern crate num; pub use base64::{u8_to_base64, base64_to_u8, big_to_base64, chunk_to_bytes}; pub use buffer::{Buff}; pub use english::{english_dict, lowercase, levenshtein, score_fn, count}; pub use xor_cipher::{single_xor, hamming}; use std::io::{File, BufferedReader, IoError}; pub mod base64; pub mod buffer; pub...
{ let path = Path::new(input); let file = match File::open(&path) { Ok(t) => t, Err(e) => fail!("Couldn't open {}, got error {}", input, e) }; let mut reader = BufferedReader::new(file); reader.lines().map(unwrap_and_noline).collect() }
identifier_body
lib.rs
extern crate num; pub use base64::{u8_to_base64, base64_to_u8, big_to_base64, chunk_to_bytes}; pub use buffer::{Buff}; pub use english::{english_dict, lowercase, levenshtein, score_fn, count}; pub use xor_cipher::{single_xor, hamming}; use std::io::{File, BufferedReader, IoError}; pub mod base64; pub mod buffer; pub...
(x: Result<String, IoError>) -> String { let mut unwrapped = x.unwrap(); let n = unwrapped.len(); unwrapped.truncate(n-1); unwrapped } pub fn read_file(input: &str) -> Vec<String> { let path = Path::new(input); let file = match File::open(&path) { Ok(t) => t, Err(e) => fail!("C...
unwrap_and_noline
identifier_name
lib.rs
extern crate num; pub use base64::{u8_to_base64, base64_to_u8, big_to_base64, chunk_to_bytes}; pub use buffer::{Buff}; pub use english::{english_dict, lowercase, levenshtein, score_fn, count}; pub use xor_cipher::{single_xor, hamming}; use std::io::{File, BufferedReader, IoError}; pub mod base64; pub mod buffer; pub...
}; let mut reader = BufferedReader::new(file); reader.lines().map(unwrap_and_noline).collect() }
random_line_split
htmlolistelement.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::HTMLOListElementBinding; use dom::bindings::codegen::InheritTypes::HTMLOList...
(localName: DOMString, prefix: Option<DOMString>, document: &Document) -> HTMLOListElement { HTMLOListElement { htmlelement: HTMLElement::new_inherited(HTMLElementTypeId::HTMLOListElement, localName, prefix, document) } } #[allow(unrooted_mu...
new_inherited
identifier_name
htmlolistelement.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::HTMLOListElementBinding; use dom::bindings::codegen::InheritTypes::HTMLOList...
}
{ let element = HTMLOListElement::new_inherited(localName, prefix, document); Node::reflect_node(box element, document, HTMLOListElementBinding::Wrap) }
identifier_body
htmlolistelement.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::HTMLOListElementBinding; use dom::bindings::codegen::InheritTypes::HTMLOList...
document: &Document) -> Root<HTMLOListElement> { let element = HTMLOListElement::new_inherited(localName, prefix, document); Node::reflect_node(box element, document, HTMLOListElementBinding::Wrap) } }
pub fn new(localName: DOMString, prefix: Option<DOMString>,
random_line_split
random_gen.rs
extern crate time; use std::sync::RwLock; pub trait PRNG { fn get(&mut self) -> u32; fn set_seed(&mut self, seed: u32); } pub fn set_seed_time(prng: &mut PRNG) { prng.set_seed((time::precise_time_ns() as f64 / 1000.0) as u32); } pub fn get_target(prng: &mut PRNG, t: u32) -> u32 { let v = get_01(prng...
} impl PRNG for Xorshift { fn get(&mut self) -> u32 { let t = self.m_x ^ (self.m_x >> 7); self.m_x = self.m_y; self.m_y = self.m_z; self.m_z = self.m_w; self.m_w = self.m_v; self.m_v = (self.m_v ^ (self.m_v << 6)) ^ (t ^ (t << 13)); (self.m_y + self.m_y + 1)...
{ let mut x = Xorshift { m_x: 0, m_y: 0, m_z: 0, m_w: 0, m_v: 0, }; x.set_seed(10000); x }
identifier_body
random_gen.rs
extern crate time; use std::sync::RwLock; pub trait PRNG { fn get(&mut self) -> u32; fn set_seed(&mut self, seed: u32); } pub fn set_seed_time(prng: &mut PRNG) { prng.set_seed((time::precise_time_ns() as f64 / 1000.0) as u32); } pub fn get_target(prng: &mut PRNG, t: u32) -> u32 { let v = get_01(prng...
() -> CMWC4096 { let mut m = CMWC4096 { m_q: [0; 4096], c: 0, }; m.set_seed(10000); m } } impl PRNG for CMWC4096 { fn get(&mut self) -> u32 { let mut t: u64; let a = 18782u64; let b = 4294967295u64; let r = b - 1; ...
new
identifier_name
random_gen.rs
extern crate time; use std::sync::RwLock; pub trait PRNG { fn get(&mut self) -> u32; fn set_seed(&mut self, seed: u32); } pub fn set_seed_time(prng: &mut PRNG) { prng.set_seed((time::precise_time_ns() as f64 / 1000.0) as u32); } pub fn get_target(prng: &mut PRNG, t: u32) -> u32 { let v = get_01(prng...
; let rg = ((high - low) + 1) as f64; let val = low as f64 + get_01(prng) * rg; val as u32 } pub fn get_01(prng: &mut PRNG) -> f64 { prng.get() as f64 / 4294967295f64 } pub struct LCG { m_state: u32, } impl LCG { pub fn new() -> LCG { let mut lcg = LCG { m_state: 0 }; lcg.set...
{ (low, high) }
conditional_block
random_gen.rs
extern crate time; use std::sync::RwLock; pub trait PRNG { fn get(&mut self) -> u32; fn set_seed(&mut self, seed: u32); } pub fn set_seed_time(prng: &mut PRNG) { prng.set_seed((time::precise_time_ns() as f64 / 1000.0) as u32); } pub fn get_target(prng: &mut PRNG, t: u32) -> u32 { let v = get_01(prng...
fn get(&mut self) -> u32 { let t = self.m_x ^ (self.m_x >> 7); self.m_x = self.m_y; self.m_y = self.m_z; self.m_z = self.m_w; self.m_w = self.m_v; self.m_v = (self.m_v ^ (self.m_v << 6)) ^ (t ^ (t << 13)); (self.m_y + self.m_y + 1) * self.m_v } fn set_...
impl PRNG for Xorshift {
random_line_split
extract_bits.rs
use word::{Word, ToWord}; /// Extract bits [`start`, `start + length`) from `x` into the lower bits /// of the result. /// /// # Keywords: /// /// Gather bit range. /// /// # Intrinsics: /// - BMI 1.0: bextr. /// /// # Examples /// /// ``` /// use bitwise::word::*; /// /// let n = 0b1011_1110_1001_0011u16; /// /// as...
<U: Word>(self, start: U, length: U) -> Self { extract_bits(self, start, length) } }
extract_bits
identifier_name
extract_bits.rs
use word::{Word, ToWord}; /// Extract bits [`start`, `start + length`) from `x` into the lower bits /// of the result. /// /// # Keywords: /// /// Gather bit range. /// /// # Intrinsics: /// - BMI 1.0: bextr. /// /// # Examples /// /// ``` /// use bitwise::word::*; /// /// let n = 0b1011_1110_1001_0011u16; /// /// as...
}
{ extract_bits(self, start, length) }
identifier_body
extract_bits.rs
use word::{Word, ToWord}; /// Extract bits [`start`, `start + length`) from `x` into the lower bits /// of the result. /// /// # Keywords: /// /// Gather bit range. /// /// # Intrinsics: /// - BMI 1.0: bextr. /// /// # Examples /// /// ```
/// /// assert_eq!(n.extract_bits(1u8, 4u8), 0b1001); /// ``` #[inline] pub fn extract_bits<T: Word, U: Word>(x: T, start: U, length: U) -> T { x.bextr(start.to(), length.to()) } /// Method version of [`extract_bits`](fn.extract_bits.html). pub trait ExtractBits { #[inline] fn extract_bits<U: Word>(self, U...
/// use bitwise::word::*; /// /// let n = 0b1011_1110_1001_0011u16;
random_line_split
lr0.rs
//! This module builds the LR(0) state machine for a given grammar. //! //! The state machine represents the state of the parser of the grammar, as tokens are produced by //! the lexer. (The details of the lexer are out of scope; for our purposes, all that is relevant is //! a sequence of tokens.) //! //! For a given s...
} derives } /// Builds a vector of symbols which are nullable. A nullable symbol is one which can be /// reduced from an empty sequence of tokens. pub(crate) fn set_nullable(gram: &Grammar) -> TVec<Symbol, bool> { let mut nullable: TVec<Symbol, bool> = TVec::from_vec(vec![false; gram.nsyms]); loop { ...
{ let mut derives = RampTable::<Rule>::with_capacity(gram.nsyms, gram.nrules); for lhs in gram.iter_var_syms() { for rule in gram.iter_rules() { if gram.rlhs(rule) == lhs { derives.push_value(rule as Rule); } } derives.finish_key(); } if l...
identifier_body
lr0.rs
//! This module builds the LR(0) state machine for a given grammar. //! //! The state machine represents the state of the parser of the grammar, as tokens are produced by //! the lexer. (The details of the lexer are out of scope; for our purposes, all that is relevant is //! a sequence of tokens.) //! //! For a given s...
(gram: &Grammar) -> RampTable<Rule> { let mut derives = RampTable::<Rule>::with_capacity(gram.nsyms, gram.nrules); for lhs in gram.iter_var_syms() { for rule in gram.iter_rules() { if gram.rlhs(rule) == lhs { derives.push_value(rule as Rule); } } d...
set_derives
identifier_name
lr0.rs
//! This module builds the LR(0) state machine for a given grammar. //! //! The state machine represents the state of the parser of the grammar, as tokens are produced by //! the lexer. (The details of the lexer are out of scope; for our purposes, all that is relevant is //! a sequence of tokens.) //! //! For a given s...
let mut rule_set: Bitv32 = Bitv32::from_elem(gram.nrules, false); let mut shift_symbol: Vec<Symbol> = Vec::new(); // this_state represents our position within our work list. The output.states // array represents both our final output, and this_state is the next state // within that array, where we...
// These vectors are used for building tables during each state. // It is inefficient to allocate and free these vectors within // the scope of processing each state. let mut item_set: Vec<Item> = Vec::with_capacity(gram.nitems());
random_line_split
lr0.rs
//! This module builds the LR(0) state machine for a given grammar. //! //! The state machine represents the state of the parser of the grammar, as tokens are produced by //! the lexer. (The details of the lexer are out of scope; for our purposes, all that is relevant is //! a sequence of tokens.) //! //! For a given s...
} i += 1; } if done { break; } } if log_enabled!(log::Level::Debug) { debug!("Nullable symbols:"); for sym in gram.iter_var_syms() { if nullable[sym] { debug!("{}", gram.name(sym)); } } ...
{ nullable[sym] = true; done = false; }
conditional_block
trait-bounds-in-arc.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...
(&self) -> usize { 4 } fn of_good_pedigree(&self) -> bool { self.bark_decibels < 70 || self.tricks_known > 20 } } impl Pet for Goldfyshe { fn name(&self, mut blk: Box<FnMut(&str)>) { blk(&self.name) } fn num_legs(&self) -> usize { 0 } fn of_good_pedigree(&self) -> bool { self.swim_speed >= 5...
num_legs
identifier_name
trait-bounds-in-arc.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...
rx1.recv(); rx2.recv(); rx3.recv(); t1.join(); t2.join(); t3.join(); } fn check_legs(arc: Arc<Vec<Box<Pet+Sync+Send>>>) { let mut legs = 0; for pet in &*arc { legs += pet.num_legs(); } assert!(legs == 12); } fn check_names(arc: Arc<Vec<Box<Pet+Sync+Send>>>) { for pet...
let t3 = thread::spawn(move|| { check_pedigree(arc3); tx3.send(()); });
random_line_split
range-1.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
pub fn main() { // Mixed types. let _ = 0u32..10i32; //~^ ERROR mismatched types // Bool => does not implement iterator. for i in false..true {} //~^ ERROR `bool: std::iter::Step` is not satisfied // Unsized type. let arr: &[_] = &[1, 2, 3]; let range = *arr..; //~^ ERROR the ...
// option. This file may not be copied, modified, or distributed // except according to those terms. // Test range syntax - type errors.
random_line_split
range-1.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 ...
() { // Mixed types. let _ = 0u32..10i32; //~^ ERROR mismatched types // Bool => does not implement iterator. for i in false..true {} //~^ ERROR `bool: std::iter::Step` is not satisfied // Unsized type. let arr: &[_] = &[1, 2, 3]; let range = *arr..; //~^ ERROR the size for val...
main
identifier_name
range-1.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 ...
{ // Mixed types. let _ = 0u32..10i32; //~^ ERROR mismatched types // Bool => does not implement iterator. for i in false..true {} //~^ ERROR `bool: std::iter::Step` is not satisfied // Unsized type. let arr: &[_] = &[1, 2, 3]; let range = *arr..; //~^ ERROR the size for values...
identifier_body
x86.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 ...
(target_triple: StrBuf, target_os: abi::Os) -> target_strs::t { return target_strs::t { module_asm: "".to_strbuf(), meta_sect_name: meta_section_name(cfg_os_to_meta_os(target_os)).to_strbuf(), data_layout: match target_os { abi::OsMacos => { ...
get_target_strs
identifier_name
x86.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 ...
abi::OsFreebsd => { "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32".to_strbuf() } }, target_triple: target_triple, cc_args: vec!("-m32".to_strbuf()), }; }
}
random_line_split
x86.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 ...
abi::OsLinux => { "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32".to_strbuf() } abi::OsAndroid => { "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32".to_strbuf() } abi::OsFreebsd => { "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:1...
{ return target_strs::t { module_asm: "".to_strbuf(), meta_sect_name: meta_section_name(cfg_os_to_meta_os(target_os)).to_strbuf(), data_layout: match target_os { abi::OsMacos => { "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16\ -i32:32:32-i64:32:64\...
identifier_body
x86.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 ...
abi::OsAndroid => { "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32".to_strbuf() } abi::OsFreebsd => { "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32".to_strbuf() } }, target_triple: target_triple, cc_args: vec!("-m32".to_s...
{ "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32".to_strbuf() }
conditional_block
macro.rs
//! [マクロクラブ Rust支部 | κeenのHappy Hacκing Blog](https://keens.github.io/blog/2018/02/17/makurokurabu_rustshibu/) macro_rules! double_println { ($ex: expr) => ( println!("{}{}", $ex, $ex); // セミコロンなしでも可 ); } macro_rules! simple_macro { // `()` はマクロが引数をとらないことを示す () => ( println!("Hello Macro!"); ); } macro_rul...
identifier_name
macro.rs
//! [マクロクラブ Rust支部 | κeenのHappy Hacκing Blog](https://keens.github.io/blog/2018/02/17/makurokurabu_rustshibu/) macro_rules! double_println { ($ex: expr) => ( println!("{}{}", $ex, $ex); // セミコロンなしでも可 ); } macro_rules! simple_macro { // `()` はマクロが引数をとらないことを示す () => (
); } macro_rules! name { // expr: 式文 ($x: expr) => ( println!("{}", $x); // 複数書く場合はセミコロン必須 // 忘れないように書いててもいいっぽい ); ($x: expr, $($y: expr), +) => ( println!("{}", $x); name!($($y), +) ); } macro_rules! fnction { // ident: 関数・変数名に使用する ($fn_name: ident) => ( fn $fn_name() { // stringify! はidentを文字列に...
println!("Hello Macro!");
random_line_split
macro.rs
//! [マクロクラブ Rust支部 | κeenのHappy Hacκing Blog](https://keens.github.io/blog/2018/02/17/makurokurabu_rustshibu/) macro_rules! double_println { ($ex: expr) => ( println!("{}{}", $ex, $ex); // セミコロンなしでも可 ); } macro_rules! simple_macro { // `()` はマクロが引数をとらないことを示す () => ( println!("Hello Macro!"); ); } macro_rul...
identifier_body
redundant_else.rs
use clippy_utils::diagnostics::span_lint_and_help; use rustc_ast::ast::{Block, Expr, ExprKind, Stmt, StmtKind}; use rustc_ast::visit::{walk_expr, Visitor}; use rustc_lint::{EarlyContext, EarlyLintPass}; use rustc_middle::lint::in_external_macro; use rustc_session::{declare_lint_pass, declare_tool_lint}; declare_clippy...
(&mut self, cx: &EarlyContext<'_>, stmt: &Stmt) { if in_external_macro(cx.sess, stmt.span) { return; } // Only look at expressions that are a whole statement let expr: &Expr = match &stmt.kind { StmtKind::Expr(expr) | StmtKind::Semi(expr) => expr, _ =>...
check_stmt
identifier_name