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
last-use-in-block.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 apply<T, F>(s: String, mut f: F) -> T where F: FnMut(String) -> T { fn g<T, F>(s: String, mut f: F) -> T where F: FnMut(String) -> T {f(s)} g(s, |v| { let r = f(v); r }) } pub fn main() {}
panic!();
random_line_split
last-use-in-block.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() {}
{ fn g<T, F>(s: String, mut f: F) -> T where F: FnMut(String) -> T {f(s)} g(s, |v| { let r = f(v); r }) }
identifier_body
layout.rs
use super::{FractionalHex,Hex}; use std::f32::consts::PI; pub struct Orientation { f: Vec<f32>, b: Vec<f32>, start_angle: f32 } impl Orientation { pub fn new(f: Vec<f32>,b: Vec<f32>,start_angle: f32) -> Orientation { Orientation { f: f, b: b, start_angle: st...
Orientation::new(vec![3.0 / 2.0, 0.0, (3.0 as f32).sqrt() / 2.0, (3.0 as f32).sqrt()], vec![2.0 / 3.0, 0.0, -1.0 / 3.0, (3.0 as f32).sqrt() / 3.0], 0.0) } } pub struct Point { pub x: f32, pub y: f32 } impl Point { pub fn new(x: f32,y: f32) -> Point { Poi...
} pub fn flat() -> Orientation {
random_line_split
layout.rs
use super::{FractionalHex,Hex}; use std::f32::consts::PI; pub struct Orientation { f: Vec<f32>, b: Vec<f32>, start_angle: f32 } impl Orientation { pub fn
(f: Vec<f32>,b: Vec<f32>,start_angle: f32) -> Orientation { Orientation { f: f, b: b, start_angle: start_angle } } pub fn pointy() -> Orientation { Orientation::new( vec![(3.0 as f32).sqrt(), (3.0 as f32).sqrt() / 2.0, 0.0, 3.0 / 2.0], ...
new
identifier_name
maildir.rs
use std::time::Duration; use crossbeam_channel::Sender; use maildir::Maildir as ExtMaildir; use serde_derive::Deserialize; use crate::blocks::{Block, ConfigBlock, Update}; use crate::config::SharedConfig; use crate::de::deserialize_duration; use crate::errors::*; use crate::scheduler::Task; use crate::widgets::text::...
}
{ self.id }
identifier_body
maildir.rs
use std::time::Duration; use crossbeam_channel::Sender; use maildir::Maildir as ExtMaildir; use serde_derive::Deserialize; use crate::blocks::{Block, ConfigBlock, Update}; use crate::config::SharedConfig; use crate::de::deserialize_duration; use crate::errors::*; use crate::scheduler::Task; use crate::widgets::text::...
(&self) -> Vec<&dyn I3BarWidget> { vec![&self.text] } fn id(&self) -> usize { self.id } }
view
identifier_name
maildir.rs
use std::time::Duration; use crossbeam_channel::Sender; use maildir::Maildir as ExtMaildir; use serde_derive::Deserialize; use crate::blocks::{Block, ConfigBlock, Update}; use crate::config::SharedConfig; use crate::de::deserialize_duration; use crate::errors::*; use crate::scheduler::Task; use crate::widgets::text::...
display_type: MailType, } //TODO add `format` #[derive(Deserialize, Debug, Clone)] #[serde(deny_unknown_fields, default)] pub struct MaildirConfig { /// Update interval in seconds #[serde(deserialize_with = "deserialize_duration")] pub interval: Duration, pub inboxes: Vec<String>, pub threshold...
threshold_critical: usize,
random_line_split
maildir.rs
use std::time::Duration; use crossbeam_channel::Sender; use maildir::Maildir as ExtMaildir; use serde_derive::Deserialize; use crate::blocks::{Block, ConfigBlock, Update}; use crate::config::SharedConfig; use crate::de::deserialize_duration; use crate::errors::*; use crate::scheduler::Task; use crate::widgets::text::...
, inboxes: block_config.inboxes, threshold_warning: block_config.threshold_warning, threshold_critical: block_config.threshold_critical, display_type: block_config.display_type, }) } } impl Block for Maildir { fn update(&mut self) -> Result<Option<Update>...
{ widget }
conditional_block
main.rs
#![feature(bool_to_option)] use std::path::Path; use log::*; use simplelog::*; use std::time::{Instant}; use clap::{Arg, App}; mod checkloc; use checkloc::checkloc; mod average; use average::average_all_images; #[macro_use] extern crate lalrpop_util; fn
() { CombinedLogger::init( vec![ TermLogger::new(LevelFilter::Debug, Config::default(), TerminalMode::Mixed), ] ).unwrap(); let mut app = App::new("krtools") .version("1.0") .author("Pedro M. <pmgberm@gmail.com>") .about("Does things the KR way") .sub...
main
identifier_name
main.rs
#![feature(bool_to_option)] use std::path::Path; use log::*; use simplelog::*; use std::time::{Instant}; use clap::{Arg, App}; mod checkloc; use checkloc::checkloc; mod average; use average::average_all_images; #[macro_use] extern crate lalrpop_util; fn main() { CombinedLogger::init( vec![ Te...
} info!(target: "kr_style_transfer", "Finished in {:?} seconds", start.elapsed().as_secs()); }
{ error!(target: "kr_style_transfer", "Unknown or unimplemented subcommand"); app.print_long_help(); }
conditional_block
main.rs
#![feature(bool_to_option)] use std::path::Path; use log::*; use simplelog::*; use std::time::{Instant}; use clap::{Arg, App}; mod checkloc; use checkloc::checkloc; mod average; use average::average_all_images; #[macro_use] extern crate lalrpop_util; fn main()
let path = Path::new(e); average_all_images(path); Some(e) }); } Some(("checkloc", args)) => { args.value_of("pdx_directory").and_then(|e| { let path = Path::new(e); checkloc(path); So...
{ CombinedLogger::init( vec![ TermLogger::new(LevelFilter::Debug, Config::default(), TerminalMode::Mixed), ] ).unwrap(); let mut app = App::new("krtools") .version("1.0") .author("Pedro M. <pmgberm@gmail.com>") .about("Does things the KR way") .su...
identifier_body
main.rs
#![feature(bool_to_option)] use std::path::Path; use log::*; use simplelog::*; use std::time::{Instant}; use clap::{Arg, App}; mod checkloc; use checkloc::checkloc; mod average; use average::average_all_images; #[macro_use] extern crate lalrpop_util; fn main() { CombinedLogger::init( vec![ Te...
} info!(target: "kr_style_transfer", "Finished in {:?} seconds", start.elapsed().as_secs()); }
_ => { error!(target: "kr_style_transfer", "Unknown or unimplemented subcommand"); app.print_long_help(); }
random_line_split
diagnostic.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 ...
// a span-handler is like a handler but also // accepts span information for source-location // reporting. pub trait span_handler { fn span_fatal(@mut self, sp: Span, msg: &str) ->!; fn span_err(@mut self, sp: Span, msg: &str); fn span_warn(@mut self, sp: Span, msg: &str); fn span_note(@mut self, sp: S...
msg: &str, lvl: level); }
random_line_split
diagnostic.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(@mut self, msg: &str) { self.emit.emit(None, msg, note); } fn bug(@mut self, msg: &str) ->! { self.fatal(ice_msg(msg)); } fn unimpl(@mut self, msg: &str) ->! { self.bug(~"unimplemented " + msg); } fn emit(@mut self, cmsp: Option<(@codemap::CodeMap, Span)>, ...
note
identifier_name
diagnostic.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 ...
&Some(ref term) => { term.attr(color); stderr.write_str(msg); term.reset(); }, _ => stderr.write_str(msg) } } else { stderr.write_str(msg); } } fn print_diagnostic(topic: &str, lvl: level, msg: &str) { let ...
{ local_data_key!(tls_terminal: @Option<term::Terminal>) let stderr = io::stderr(); if stderr.get_type() == io::Screen { let t = match local_data::get(tls_terminal, |v| v.map_move(|k| *k)) { None => { let t = term::Terminal::new(stderr); let tls = @match...
identifier_body
borrowck-borrow-of-mut-base-ptr-safe.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 ...
() { }
main
identifier_name
borrowck-borrow-of-mut-base-ptr-safe.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 ...
// pretty-expanded FIXME #23616 fn foo<'a>(mut t0: &'a mut isize, mut t1: &'a mut isize) { let p: &isize = &*t0; // Freezes `*t0` let mut t2 = &t0; let q: &isize = &**t2; // Freezes `*t0`, but that's ok... let r: &isize = &*t0; //...after all, could do same thing directly. } pub fn main() {...
random_line_split
borrowck-borrow-of-mut-base-ptr-safe.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 ...
{ }
identifier_body
content_length.rs
use std::fmt; use header::{Header, Raw, parsing}; /// `Content-Length` header, defined in /// [RFC7230](http://tools.ietf.org/html/rfc7230#section-3.3.2) /// /// When a message does not have a `Transfer-Encoding` header field, a /// Content-Length header field can provide the anticipated size, as a /// decimal numbe...
/// headers.set(ContentLength(1024u64)); /// ``` #[derive(Clone, Copy, Debug, PartialEq)] pub struct ContentLength(pub u64); //static NAME: &'static str = "Content-Length"; impl Header for ContentLength { #[inline] fn header_name() -> &'static str { static NAME: &'static str = "Content-Length"; ...
/// ``` /// use hyper::header::{Headers, ContentLength}; /// /// let mut headers = Headers::new();
random_line_split
content_length.rs
use std::fmt; use header::{Header, Raw, parsing}; /// `Content-Length` header, defined in /// [RFC7230](http://tools.ietf.org/html/rfc7230#section-3.3.2) /// /// When a message does not have a `Transfer-Encoding` header field, a /// Content-Length header field can provide the anticipated size, as a /// decimal numbe...
fn parse_header(raw: &Raw) -> ::Result<ContentLength> { // If multiple Content-Length headers were sent, everything can still // be alright if they all contain the same value, and all parse // correctly. If not, then it's an error. raw.iter() .map(parsing::from_raw_str) ...
{ static NAME: &'static str = "Content-Length"; NAME }
identifier_body
content_length.rs
use std::fmt; use header::{Header, Raw, parsing}; /// `Content-Length` header, defined in /// [RFC7230](http://tools.ietf.org/html/rfc7230#section-3.3.2) /// /// When a message does not have a `Transfer-Encoding` header field, a /// Content-Length header field can provide the anticipated size, as a /// decimal numbe...
(&self, f: &mut ::header::Formatter) -> fmt::Result { f.fmt_line(self) } } impl fmt::Display for ContentLength { #[inline] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Display::fmt(&self.0, f) } } __hyper__deref!(ContentLength => u64); __hyper__tm!(ContentLength, tests ...
fmt_header
identifier_name
server_decoration.rs
//! Support for the KDE Server Decoration Protocol use crate::wayland_sys::server::wl_display as wl_server_display; pub use wlroots_sys::protocols::server_decoration::server::org_kde_kwin_server_decoration_manager::Mode; use wlroots_sys::{ wl_display, wlr_server_decoration_manager, wlr_server_decoration_manager_cr...
else { None } } /// Given a mode, set the server decoration mode pub fn set_default_mode(&mut self, mode: Mode) { wlr_log!(WLR_INFO, "New server decoration mode: {:?}", mode); unsafe { wlr_server_decoration_manager_set_default_mode(self.manager, mode.to_raw()) } } }...
{ Some(Manager { manager: manager_raw }) }
conditional_block
server_decoration.rs
//! Support for the KDE Server Decoration Protocol use crate::wayland_sys::server::wl_display as wl_server_display; pub use wlroots_sys::protocols::server_decoration::server::org_kde_kwin_server_decoration_manager::Mode; use wlroots_sys::{ wl_display, wlr_server_decoration_manager, wlr_server_decoration_manager_cr...
} impl Drop for Manager { fn drop(&mut self) { unsafe { wlr_server_decoration_manager_destroy(self.manager) } } }
{ wlr_log!(WLR_INFO, "New server decoration mode: {:?}", mode); unsafe { wlr_server_decoration_manager_set_default_mode(self.manager, mode.to_raw()) } }
identifier_body
server_decoration.rs
//! Support for the KDE Server Decoration Protocol use crate::wayland_sys::server::wl_display as wl_server_display; pub use wlroots_sys::protocols::server_decoration::server::org_kde_kwin_server_decoration_manager::Mode; use wlroots_sys::{ wl_display, wlr_server_decoration_manager, wlr_server_decoration_manager_cr...
(&mut self, mode: Mode) { wlr_log!(WLR_INFO, "New server decoration mode: {:?}", mode); unsafe { wlr_server_decoration_manager_set_default_mode(self.manager, mode.to_raw()) } } } impl Drop for Manager { fn drop(&mut self) { unsafe { wlr_server_decoration_manager_destroy(self.manager) } ...
set_default_mode
identifier_name
server_decoration.rs
pub use wlroots_sys::protocols::server_decoration::server::org_kde_kwin_server_decoration_manager::Mode; use wlroots_sys::{ wl_display, wlr_server_decoration_manager, wlr_server_decoration_manager_create, wlr_server_decoration_manager_destroy, wlr_server_decoration_manager_set_default_mode }; #[derive(Debug)] ...
//! Support for the KDE Server Decoration Protocol use crate::wayland_sys::server::wl_display as wl_server_display;
random_line_split
pointing.mako.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ <%namespace name="helpers" file="/helpers.mako.rs" /> <% data.new_style_struct("Pointing", inherited=True, gecko_...
use style_traits::cursor::Cursor; #[derive(Clone, PartialEq, Eq, Copy, Debug)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum T { AutoCursor, SpecifiedCursor(Cursor), } impl ToCss for T { fn to_css<W>(&self, dest: &mut W)...
use cssparser::ToCss; use std::fmt;
random_line_split
pointing.mako.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ <%namespace name="helpers" file="/helpers.mako.rs" /> <% data.new_style_struct("Pointing", inherited=True, gecko_...
</%helpers:longhand> // NB: `pointer-events: auto` (and use of `pointer-events` in anything that isn't SVG, in fact) // is nonstandard, slated for CSS4-UI. // TODO(pcwalton): SVG-only values. ${helpers.single_keyword("pointer-events", "auto none")} ${helpers.single_keyword("-moz-user-input", "none enabled disabled",...
{ use std::ascii::AsciiExt; use style_traits::cursor::Cursor; let ident = try!(input.expect_ident()); if ident.eq_ignore_ascii_case("auto") { Ok(SpecifiedValue::AutoCursor) } else { Cursor::from_css_keyword(&ident) .map(SpecifiedValue::Specifie...
identifier_body
pointing.mako.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ <%namespace name="helpers" file="/helpers.mako.rs" /> <% data.new_style_struct("Pointing", inherited=True, gecko_...
(_context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> { use std::ascii::AsciiExt; use style_traits::cursor::Cursor; let ident = try!(input.expect_ident()); if ident.eq_ignore_ascii_case("auto") { Ok(SpecifiedValue::AutoCursor) } else { ...
parse
identifier_name
pointing.mako.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ <%namespace name="helpers" file="/helpers.mako.rs" /> <% data.new_style_struct("Pointing", inherited=True, gecko_...
else { Cursor::from_css_keyword(&ident) .map(SpecifiedValue::SpecifiedCursor) } } </%helpers:longhand> // NB: `pointer-events: auto` (and use of `pointer-events` in anything that isn't SVG, in fact) // is nonstandard, slated for CSS4-UI. // TODO(pcwalton): SVG-only values. ${helpers...
{ Ok(SpecifiedValue::AutoCursor) }
conditional_block
font_context.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 crate app_units; extern crate gfx; extern crate servo_arc; extern crate servo_atoms; extern crate style; ex...
#[test] fn test_font_group_find_by_codepoint() { let source = TestFontSource::new(); let count = source.find_font_count.clone(); let mut context = FontContext::new(source); let mut style = style(); style.set_font_family(font_family(vec!["CSSTest ASCII", "CSSTest Basic"])); let group = context....
"different font groups should be returned for two styles with different hashes" ) }
random_line_split
font_context.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 crate app_units; extern crate gfx; extern crate servo_arc; extern crate servo_atoms; extern crate style; ex...
) { let source = TestFontSource::new(); let mut context = FontContext::new(source); let mut style = style(); style.set_font_family(font_family(vec!["CSSTest ASCII"])); let group = context.font_group(Arc::new(style)); let font = group .borrow_mut() .find_by_codepoint(&mut context...
est_font_fallback(
identifier_name
framebuffer_info.rs
//! Handles the framebuffer information tag. use super::get_tag; #[cfg(target_arch = "x86_64")] use arch::vga_buffer; use memory::{Address, VirtualAddress}; /// Represents the framebuffer information tag. #[repr(C)] pub struct FramebufferInfo { // type = 8 tag_type: u32, size: u32, pub framebuffer_add...
() -> vga_buffer::Info { let framebuffer_tag = get_tag(8); match framebuffer_tag { Some(framebuffer_tag_address) => { let framebuffer_tag = unsafe { &*(framebuffer_tag_address as *const FramebufferInfo) }; vga_buffer::Info { height: framebuffer_tag.framebuffer_hei...
get_vga_info
identifier_name
framebuffer_info.rs
//! Handles the framebuffer information tag. use super::get_tag; #[cfg(target_arch = "x86_64")] use arch::vga_buffer; use memory::{Address, VirtualAddress}; /// Represents the framebuffer information tag. #[repr(C)] pub struct FramebufferInfo { // type = 8 tag_type: u32, size: u32, pub framebuffer_add...
vga_buffer::Info { height: framebuffer_tag.framebuffer_height as usize, width: framebuffer_tag.framebuffer_width as usize, address: VirtualAddress::from_usize(to_virtual!(framebuffer_tag.framebuffer_addr)) } }, None => vga_buffer::I...
random_line_split
object-lifetime-default-ambiguous.rs
// Test that if a struct declares multiple region bounds for a given // type parameter, an explicit lifetime bound is required on object // lifetimes within. #![allow(dead_code)] trait Test { fn foo(&self) { } } struct Ref0<T:?Sized> { r: *mut T } struct Ref1<'a,T:'a+?Sized> { r: &'a T } struct Ref2<'a...
} fn d(t: Ref2<Ref1<dyn Test>>) { // In this case, the lifetime parameter from the Ref1 overrides. } fn e(t: Ref2<Ref0<dyn Test>>) { // In this case, Ref2 is ambiguous, but Ref0 overrides with'static. } fn f(t: &Ref2<dyn Test>) { //~^ ERROR lifetime bound for this object type cannot be deduced from conte...
fn c(t: Ref2<&dyn Test>) { // In this case, the &'a overrides.
random_line_split
object-lifetime-default-ambiguous.rs
// Test that if a struct declares multiple region bounds for a given // type parameter, an explicit lifetime bound is required on object // lifetimes within. #![allow(dead_code)] trait Test { fn foo(&self) { } } struct Ref0<T:?Sized> { r: *mut T } struct Ref1<'a,T:'a+?Sized> { r: &'a T } struct Ref2<'a...
<'a,'b>(t: Ref2<'a,'b, dyn Test>) { //~^ ERROR lifetime bound for this object type cannot be deduced from context } fn b(t: Ref2<dyn Test>) { //~^ ERROR lifetime bound for this object type cannot be deduced from context } fn c(t: Ref2<&dyn Test>) { // In this case, the &'a overrides. } fn d(t: Ref2<Ref1<...
a
identifier_name
object-lifetime-default-ambiguous.rs
// Test that if a struct declares multiple region bounds for a given // type parameter, an explicit lifetime bound is required on object // lifetimes within. #![allow(dead_code)] trait Test { fn foo(&self) { } } struct Ref0<T:?Sized> { r: *mut T } struct Ref1<'a,T:'a+?Sized> { r: &'a T } struct Ref2<'a...
fn main() { }
{ //~^ ERROR lifetime bound for this object type cannot be deduced from context }
identifier_body
attr.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::parser::SelectorImpl; use cssparser::ToCss; use std::fmt; #[derive(Clone, Eq, PartialEq, ToShmem)] #[...
<NamespaceUrl> { Any, /// Empty string for no namespace Specific(NamespaceUrl), } #[derive(Clone, Eq, PartialEq, ToShmem)] pub enum ParsedAttrSelectorOperation<AttrValue> { Exists, WithValue { operator: AttrSelectorOperator, case_sensitivity: ParsedCaseSensitivity, expected...
NamespaceConstraint
identifier_name
attr.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::parser::SelectorImpl; use cssparser::ToCss; use std::fmt; #[derive(Clone, Eq, PartialEq, ToShmem)] #[...
#[derive(Clone, Copy, Eq, PartialEq, ToShmem)] pub enum AttrSelectorOperator { Equal, Includes, DashMatch, Prefix, Substring, Suffix, } impl ToCss for AttrSelectorOperator { fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write, { // https://drafts.css...
random_line_split
attr.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::parser::SelectorImpl; use cssparser::ToCss; use std::fmt; #[derive(Clone, Eq, PartialEq, ToShmem)] #[...
ParsedCaseSensitivity::CaseSensitive | ParsedCaseSensitivity::ExplicitCaseSensitive => { CaseSensitivity::CaseSensitive }, ParsedCaseSensitivity::AsciiCaseInsensitive => CaseSensitivity::AsciiCaseInsensitive, } } } #[derive(Clone, Copy, Debug, Eq, Partia...
CaseSensitivity::CaseSensitive },
conditional_block
attr.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::parser::SelectorImpl; use cssparser::ToCss; use std::fmt; #[derive(Clone, Eq, PartialEq, ToShmem)] #[...
pub fn contains(self, haystack: &str, needle: &str) -> bool { match self { CaseSensitivity::CaseSensitive => haystack.contains(needle), CaseSensitivity::AsciiCaseInsensitive => { if let Some((&n_first_byte, n_rest)) = needle.as_bytes().split_first() { ...
match self { CaseSensitivity::CaseSensitive => a == b, CaseSensitivity::AsciiCaseInsensitive => a.eq_ignore_ascii_case(b), } }
identifier_body
lib.rs
// Copyright 2013-2018, The Gtk-rs Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or <https://opensource.org/licenses/MIT> #![allow(deprecated)] #![cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))] #![c...
mod time_coord; mod visual; mod window; pub use gdk_sys::GdkColor as Color; pub use self::rt::{init, set_initialized}; pub use atom::Atom; pub use atom::NONE as ATOM_NONE; pub use atom::SELECTION_CLIPBOARD; pub use atom::SELECTION_PRIMARY; pub use atom::SELECTION_SECONDARY; pub use atom::SELECTION_TYPE_ATOM; pub use...
mod rgba; mod screen;
random_line_split
macros.rs
// Copyright 2013 The Servo Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution. // // 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 ...
mint::$std_name { $( $field: self.$field, )* } } } } }
#[cfg(feature = "mint")] impl<T, U> Into<mint::$std_name<T>> for $name<T, U> { fn into(self) -> mint::$std_name<T> {
random_line_split
i2c_ds3231.rs
// i2c_ds3231.rs - Sets and retrieves the time on a Maxim Integrated DS3231 // RTC using I2C. use std::error::Error; use std::thread; use std::time::Duration; use rppal::i2c::I2c; // DS3231 I2C default slave address. const ADDR_DS3231: u16 = 0x68;
const REG_SECONDS: usize = 0x00; const REG_MINUTES: usize = 0x01; const REG_HOURS: usize = 0x02; // Helper functions to encode and decode binary-coded decimal (BCD) values. fn bcd2dec(bcd: u8) -> u8 { (((bcd & 0xF0) >> 4) * 10) + (bcd & 0x0F) } fn dec2bcd(dec: u8) -> u8 { ((dec / 10) << 4) | (dec % 10) } fn ...
// DS3231 register addresses.
random_line_split
i2c_ds3231.rs
// i2c_ds3231.rs - Sets and retrieves the time on a Maxim Integrated DS3231 // RTC using I2C. use std::error::Error; use std::thread; use std::time::Duration; use rppal::i2c::I2c; // DS3231 I2C default slave address. const ADDR_DS3231: u16 = 0x68; // DS3231 register addresses. const REG_SECONDS: usize = 0x00; const...
fn dec2bcd(dec: u8) -> u8 { ((dec / 10) << 4) | (dec % 10) } fn main() -> Result<(), Box<dyn Error>> { let mut i2c = I2c::new()?; // Set the I2C slave address to the device we're communicating with. i2c.set_slave_address(ADDR_DS3231)?; // Set the time to 11:59:50 AM. Start at register address 0...
{ (((bcd & 0xF0) >> 4) * 10) + (bcd & 0x0F) }
identifier_body
i2c_ds3231.rs
// i2c_ds3231.rs - Sets and retrieves the time on a Maxim Integrated DS3231 // RTC using I2C. use std::error::Error; use std::thread; use std::time::Duration; use rppal::i2c::I2c; // DS3231 I2C default slave address. const ADDR_DS3231: u16 = 0x68; // DS3231 register addresses. const REG_SECONDS: usize = 0x00; const...
(bcd: u8) -> u8 { (((bcd & 0xF0) >> 4) * 10) + (bcd & 0x0F) } fn dec2bcd(dec: u8) -> u8 { ((dec / 10) << 4) | (dec % 10) } fn main() -> Result<(), Box<dyn Error>> { let mut i2c = I2c::new()?; // Set the I2C slave address to the device we're communicating with. i2c.set_slave_address(ADDR_DS3231)?;...
bcd2dec
identifier_name
i2c_ds3231.rs
// i2c_ds3231.rs - Sets and retrieves the time on a Maxim Integrated DS3231 // RTC using I2C. use std::error::Error; use std::thread; use std::time::Duration; use rppal::i2c::I2c; // DS3231 I2C default slave address. const ADDR_DS3231: u16 = 0x68; // DS3231 register addresses. const REG_SECONDS: usize = 0x00; const...
else { // 24-hour format. println!( "{:0>2}:{:0>2}:{:0>2}", bcd2dec(reg[REG_HOURS] & 0x3F), bcd2dec(reg[REG_MINUTES]), bcd2dec(reg[REG_SECONDS]) ); } thread::sleep(Duration::from_secs(1)); } }
{ // 12-hour format. println!( "{:0>2}:{:0>2}:{:0>2} {}", bcd2dec(reg[REG_HOURS] & 0x1F), bcd2dec(reg[REG_MINUTES]), bcd2dec(reg[REG_SECONDS]), if reg[REG_HOURS] & (1 << 5) > 0 { "PM" ...
conditional_block
dfs.rs
//! `PathExplorer` that works by exploring the CFG in Depth First Order. use std::collections::VecDeque; use libsmt::theories::core; use explorer::explorer::PathExplorer; use engine::rune::RuneControl; use context::context::{Context, Evaluate, RegisterRead}; use context::rune_ctx::RuneContext; #[derive(Clone, Copy,...
} #[derive(Clone, Debug)] struct SavedState<C: Context> { pub ctx: C, pub branch: BranchType, } impl<C: Context> SavedState<C> { fn new(ctx: C, b: BranchType) -> SavedState<C> { SavedState { ctx: ctx, branch: b, } } } /// An explorer that traverses the program ...
random_line_split
dfs.rs
//! `PathExplorer` that works by exploring the CFG in Depth First Order. use std::collections::VecDeque; use libsmt::theories::core; use explorer::explorer::PathExplorer; use engine::rune::RuneControl; use context::context::{Context, Evaluate, RegisterRead}; use context::rune_ctx::RuneContext; #[derive(Clone, Copy,...
else { None } } fn register_branch(&mut self, ctx: &mut Self::Ctx, condition: <Self::Ctx as RegisterRead>::VarRef) -> RuneControl { // When a new branch is encountered, push the false branch into the queue and ...
{ *ctx = state.ctx.clone(); Some(match state.branch { BranchType::True => RuneControl::ExploreTrue, BranchType::False => RuneControl::ExploreFalse, }) }
conditional_block
dfs.rs
//! `PathExplorer` that works by exploring the CFG in Depth First Order. use std::collections::VecDeque; use libsmt::theories::core; use explorer::explorer::PathExplorer; use engine::rune::RuneControl; use context::context::{Context, Evaluate, RegisterRead}; use context::rune_ctx::RuneContext; #[derive(Clone, Copy,...
{ True, False, } #[derive(Clone, Debug)] struct SavedState<C: Context> { pub ctx: C, pub branch: BranchType, } impl<C: Context> SavedState<C> { fn new(ctx: C, b: BranchType) -> SavedState<C> { SavedState { ctx: ctx, branch: b, } } } /// An explorer tha...
BranchType
identifier_name
dfs.rs
//! `PathExplorer` that works by exploring the CFG in Depth First Order. use std::collections::VecDeque; use libsmt::theories::core; use explorer::explorer::PathExplorer; use engine::rune::RuneControl; use context::context::{Context, Evaluate, RegisterRead}; use context::rune_ctx::RuneContext; #[derive(Clone, Copy,...
fn register_branch(&mut self, ctx: &mut Self::Ctx, condition: <Self::Ctx as RegisterRead>::VarRef) -> RuneControl { // When a new branch is encountered, push the false branch into the queue and // explore the // true bran...
{ if let Some(ref state) = self.queue.pop_back() { *ctx = state.ctx.clone(); Some(match state.branch { BranchType::True => RuneControl::ExploreTrue, BranchType::False => RuneControl::ExploreFalse, }) } else { None } ...
identifier_body
chacha.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> SeedableRng<&'a [u32]> for ChaChaRng { fn reseed(&mut self, seed: &'a [u32]) { // reset state self.init(&[0u32,..KEY_WORDS]); // set key inplace let key = self.state.slice_mut(4, 4+KEY_WORDS); for (k, s) in key.iter_mut().zip(seed.iter()) { *k = *s; ...
{ if self.index == STATE_WORDS { self.update(); } let value = self.buffer[self.index % STATE_WORDS]; self.index += 1; value }
identifier_body
chacha.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 ...
() { // Test vectors 1 and 2 from // http://tools.ietf.org/html/draft-nir-cfrg-chacha20-poly1305-04 let seed : &[_] = &[0u32,..8]; let mut ra: ChaChaRng = SeedableRng::from_seed(seed); let v = Vec::from_fn(16, |_| ra.next_u32()); assert_eq!(v, vec!(0xa...
test_rng_true_values
identifier_name
chacha.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 ...
let value = self.buffer[self.index % STATE_WORDS]; self.index += 1; value } } impl<'a> SeedableRng<&'a [u32]> for ChaChaRng { fn reseed(&mut self, seed: &'a [u32]) { // reset state self.init(&[0u32,..KEY_WORDS]); // set key inplace let key = self.state...
{ self.update(); }
conditional_block
chacha.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 ...
/// /// The ChaCha algorithm is widely accepted as suitable for /// cryptographic purposes, but this implementation has not been /// verified as such. Prefer a generator like `OsRng` that defers to /// the operating system for cases that need high security. /// /// [1]: D. J. Bernstein, [*ChaCha, a variant of /// Salsa...
const CHACHA_ROUNDS: uint = 20; // Cryptographically secure from 8 upwards as of this writing /// A random number generator that uses the ChaCha20 algorithm [1].
random_line_split
audio.rs
use cpal::traits::{DeviceTrait, HostTrait, StreamTrait}; use ringbuf::{Producer, RingBuffer}; pub struct AudioPlayer { buffer_producer: Producer<f32>, output_stream: cpal::Stream, } impl AudioPlayer { pub fn new(sample_rate: u32) -> Self { let host = cpal::default_host(); let output_device...
(&self) { self.output_stream.play().unwrap(); } /// Pause the player /// > not used for now, but maybe later #[allow(dead_code)] pub fn pause(&self) { self.output_stream.pause().unwrap(); } pub fn queue(&mut self, data: &[f32]) { self.buffer_producer.push_slice(data...
play
identifier_name
audio.rs
use cpal::traits::{DeviceTrait, HostTrait, StreamTrait}; use ringbuf::{Producer, RingBuffer}; pub struct AudioPlayer { buffer_producer: Producer<f32>, output_stream: cpal::Stream, } impl AudioPlayer { pub fn new(sample_rate: u32) -> Self { let host = cpal::default_host(); let output_device...
.expect("failed to get default output audio device"); let config = cpal::StreamConfig { channels: 2, sample_rate: cpal::SampleRate(sample_rate), buffer_size: cpal::BufferSize::Default, }; // Limiting the number of samples in the buffer is better t...
.default_output_device()
random_line_split
snippet.rs
// # Snippet example // // This example shows how to return a representative snippet of // your hit result. // Snippet are an extracted of a target document, and returned in HTML format. // The keyword searched by the user are highlighted with a `<b>` tag. // --- // Importing tantivy... use tantivy::collector::TopDocs...
bank and runs deep and green. The water is warm too, for it has slipped twinkling \ over the yellow sands in the sunlight before reaching the narrow pool. On one \ side of the river the golden foothill slopes curve up to the strong and rocky \ Gabilan Mountains, but on th...
{ // Let's create a temporary directory for the // sake of this example let index_path = TempDir::new()?; // # Defining the schema let mut schema_builder = Schema::builder(); let title = schema_builder.add_text_field("title", TEXT | STORED); let body = schema_builder.add_text_field("body", ...
identifier_body
snippet.rs
// # Snippet example // // This example shows how to return a representative snippet of // your hit result. // Snippet are an extracted of a target document, and returned in HTML format. // The keyword searched by the user are highlighted with a `<b>` tag. // --- // Importing tantivy... use tantivy::collector::TopDocs...
let doc = searcher.doc(doc_address)?; let snippet = snippet_generator.snippet_from_doc(&doc); println!("Document score {}:", score); println!("title: {}", doc.get_first(title).unwrap().text().unwrap()); println!("snippet: {}", snippet.to_html()); println!("custom highligh...
let snippet_generator = SnippetGenerator::create(&searcher, &*query, body)?; for (score, doc_address) in top_docs {
random_line_split
snippet.rs
// # Snippet example // // This example shows how to return a representative snippet of // your hit result. // Snippet are an extracted of a target document, and returned in HTML format. // The keyword searched by the user are highlighted with a `<b>` tag. // --- // Importing tantivy... use tantivy::collector::TopDocs...
() -> tantivy::Result<()> { // Let's create a temporary directory for the // sake of this example let index_path = TempDir::new()?; // # Defining the schema let mut schema_builder = Schema::builder(); let title = schema_builder.add_text_field("title", TEXT | STORED); let body = schema_build...
main
identifier_name
same_struct_name_in_different_namespaces.rs
/* automatically generated by rust-bindgen */ #![allow( dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals )] #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct
{ _unused: [u8; 0], } #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct JS_shadow_Zone { pub x: ::std::os::raw::c_int, pub y: ::std::os::raw::c_int, } #[test] fn bindgen_test_layout_JS_shadow_Zone() { assert_eq!( ::std::mem::size_of::<JS_shadow_Zone>(), 8usize, concat...
JS_Zone
identifier_name
same_struct_name_in_different_namespaces.rs
/* automatically generated by rust-bindgen */ #![allow( dead_code, non_snake_case,
#[repr(C)] #[derive(Debug, Copy, Clone)] pub struct JS_Zone { _unused: [u8; 0], } #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct JS_shadow_Zone { pub x: ::std::os::raw::c_int, pub y: ::std::os::raw::c_int, } #[test] fn bindgen_test_layout_JS_shadow_Zone() { assert_eq!( ::std::mem:...
non_camel_case_types, non_upper_case_globals )]
random_line_split
main.rs
use std::hash::{Hash, Hasher}; use std::collections::HashSet; #[derive(Debug, Clone, Copy)] struct Foo { elem: usize, } impl PartialEq for Foo { #[inline] fn eq(&self, other: &Self) -> bool { self as *const Self == other as *const Self } } impl Eq for Foo {} impl Hash for Foo { #[inline] fn hash<H: ...
} fn main() { let a = Foo { elem: 5 }; let b = a.clone(); let c = a; let mut set = HashSet::new(); assert!(a!= b); assert!(a!= c); assert!(b!= c); if!set.insert(a) { unreachable!(); } if!set.insert(b) { unreachable!(); } if!set.insert(c) { unreachable!(); } println!("{:#...
{ (self as *const Self).hash(state); }
identifier_body
main.rs
use std::hash::{Hash, Hasher}; use std::collections::HashSet; #[derive(Debug, Clone, Copy)] struct Foo { elem: usize, } impl PartialEq for Foo { #[inline] fn eq(&self, other: &Self) -> bool { self as *const Self == other as *const Self } } impl Eq for Foo {} impl Hash for Foo { #[inline] fn hash<H: ...
let a = Foo { elem: 5 }; let b = a.clone(); let c = a; let mut set = HashSet::new(); assert!(a!= b); assert!(a!= c); assert!(b!= c); if!set.insert(a) { unreachable!(); } if!set.insert(b) { unreachable!(); } if!set.insert(c) { unreachable!(); } println!("{:#?}", set); }
fn main() {
random_line_split
main.rs
use std::hash::{Hash, Hasher}; use std::collections::HashSet; #[derive(Debug, Clone, Copy)] struct
{ elem: usize, } impl PartialEq for Foo { #[inline] fn eq(&self, other: &Self) -> bool { self as *const Self == other as *const Self } } impl Eq for Foo {} impl Hash for Foo { #[inline] fn hash<H: Hasher>(&self, state: &mut H) { (self as *const Self).hash(state); } } fn main() { let a = Fo...
Foo
identifier_name
main.rs
use std::hash::{Hash, Hasher}; use std::collections::HashSet; #[derive(Debug, Clone, Copy)] struct Foo { elem: usize, } impl PartialEq for Foo { #[inline] fn eq(&self, other: &Self) -> bool { self as *const Self == other as *const Self } } impl Eq for Foo {} impl Hash for Foo { #[inline] fn hash<H: ...
if!set.insert(c) { unreachable!(); } println!("{:#?}", set); }
{ unreachable!(); }
conditional_block
test_multicast.rs
use mio::*; use mio::udp::*; use bytes::{Buf, RingBuf, SliceBuf}; use std::str; use std::net::{SocketAddr};
const LISTENER: Token = Token(0); const SENDER: Token = Token(1); pub struct UdpHandler { tx: UdpSocket, rx: UdpSocket, msg: &'static str, buf: SliceBuf<'static>, rx_buf: RingBuf } impl UdpHandler { fn new(tx: UdpSocket, rx: UdpSocket, msg: &'static str) -> UdpHandler { UdpHandler { ...
use super::localhost;
random_line_split
test_multicast.rs
use mio::*; use mio::udp::*; use bytes::{Buf, RingBuf, SliceBuf}; use std::str; use std::net::{SocketAddr}; use super::localhost; const LISTENER: Token = Token(0); const SENDER: Token = Token(1); pub struct UdpHandler { tx: UdpSocket, rx: UdpSocket, msg: &'static str, buf: SliceBuf<'static>, rx_bu...
(tx: UdpSocket, rx: UdpSocket, msg: &'static str) -> UdpHandler { UdpHandler { tx: tx, rx: rx, msg: msg, buf: SliceBuf::wrap(msg.as_bytes()), rx_buf: RingBuf::new(1024) } } fn handle_read(&mut self, event_loop: &mut EventLoop<UdpHandle...
new
identifier_name
test_multicast.rs
use mio::*; use mio::udp::*; use bytes::{Buf, RingBuf, SliceBuf}; use std::str; use std::net::{SocketAddr}; use super::localhost; const LISTENER: Token = Token(0); const SENDER: Token = Token(1); pub struct UdpHandler { tx: UdpSocket, rx: UdpSocket, msg: &'static str, buf: SliceBuf<'static>, rx_bu...
} impl Handler for UdpHandler { type Timeout = usize; type Message = (); fn ready(&mut self, event_loop: &mut EventLoop<UdpHandler>, token: Token, events: EventSet) { if events.is_readable() { self.handle_read(event_loop, token, events); } if events.is_writable() { ...
{ match token { SENDER => { self.tx.send_to(&mut self.buf, &self.rx.local_addr().unwrap()).unwrap(); }, _ => () } }
identifier_body
test_multicast.rs
use mio::*; use mio::udp::*; use bytes::{Buf, RingBuf, SliceBuf}; use std::str; use std::net::{SocketAddr}; use super::localhost; const LISTENER: Token = Token(0); const SENDER: Token = Token(1); pub struct UdpHandler { tx: UdpSocket, rx: UdpSocket, msg: &'static str, buf: SliceBuf<'static>, rx_bu...
} } #[test] pub fn test_multicast() { debug!("Starting TEST_UDP_CONNECTIONLESS"); let mut event_loop = EventLoop::new().unwrap(); let addr = localhost(); let any = "0.0.0.0:0".parse().unwrap(); let tx = UdpSocket::bound(&any).unwrap(); let rx = UdpSocket::bound(&addr).unwrap(); info...
{ self.handle_write(event_loop, token, events); }
conditional_block
global.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/. */ //! Abstractions for global scopes. //! //! This module contains smart pointers to global scopes, to simplify writ...
(global: &GlobalRef) -> GlobalField { match *global { Window(window) => WindowField(JS::from_rooted(window)), Worker(worker) => WorkerField(JS::from_rooted(worker)), } } /// Create a stack-bounded root for this reference. pub fn root(&self) -> GlobalRoot { ma...
from_rooted
identifier_name
global.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/. */ //! Abstractions for global scopes. //! //! This module contains smart pointers to global scopes, to simplify writ...
} } impl GlobalField { /// Create a new `GlobalField` from a rooted reference. pub fn from_rooted(global: &GlobalRef) -> GlobalField { match *global { Window(window) => WindowField(JS::from_rooted(window)), Worker(worker) => WorkerField(JS::from_rooted(worker)), } ...
WorkerRoot(ref worker) => Worker(worker.root_ref()), }
random_line_split
util.rs
// Copyright 2020 TiKV Project Authors. Licensed under Apache-2.0. use std::io::{self, Error, ErrorKind}; use rusoto_core::{ region::Region, request::{HttpClient, HttpConfig}, }; use rusoto_credential::{ AutoRefreshingProvider, AwsCredentials, ChainProvider, CredentialsError, ProvideAwsCredentials, }; use...
Err(e) => e, }; let def_error = match def_creds.await { res @ Ok(_) => return res, Err(e) => e, }; Err(CredentialsError::new(format_args!( "Couldn't find AWS credentials in default sources ({}) or k8s environment ({}).", def_err...
res @ Ok(_) => return res,
random_line_split
util.rs
// Copyright 2020 TiKV Project Authors. Licensed under Apache-2.0. use std::io::{self, Error, ErrorKind}; use rusoto_core::{ region::Region, request::{HttpClient, HttpConfig}, }; use rusoto_credential::{ AutoRefreshingProvider, AwsCredentials, ChainProvider, CredentialsError, ProvideAwsCredentials, }; use...
(&self) -> Result<AwsCredentials, CredentialsError> { // Prefer the web identity provider first for the kubernetes environment. // Search for both in parallel. let web_creds = self.web_identity_provider.credentials(); let def_creds = self.default_provider.credentials(); let k8s_e...
credentials
identifier_name
util.rs
// Copyright 2020 TiKV Project Authors. Licensed under Apache-2.0. use std::io::{self, Error, ErrorKind}; use rusoto_core::{ region::Region, request::{HttpClient, HttpConfig}, }; use rusoto_credential::{ AutoRefreshingProvider, AwsCredentials, ChainProvider, CredentialsError, ProvideAwsCredentials, }; use...
} #[async_trait] impl ProvideAwsCredentials for DefaultCredentialsProvider { async fn credentials(&self) -> Result<AwsCredentials, CredentialsError> { // Prefer the web identity provider first for the kubernetes environment. // Search for both in parallel. let web_creds = self.web_identity...
{ DefaultCredentialsProvider { default_provider: ChainProvider::new(), web_identity_provider: WebIdentityProvider::from_k8s_env(), } }
identifier_body
trait-inheritance-cross-trait-call.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 a = &A { x: 3 }; assert!(a.g() == 10); }
main
identifier_name
trait-inheritance-cross-trait-call.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 ...
impl Foo for A { fn f(&self) -> int { 10 } } impl Bar for A { // Testing that this impl can call the impl of Foo fn g(&self) -> int { self.f() } } pub fn main() { let a = &A { x: 3 }; assert!(a.g() == 10); }
struct A { x: int }
random_line_split
parse_grammar.rs
use super::grammars::{InputGrammar, PrecedenceEntry, Variable, VariableType}; use super::rules::{Precedence, Rule}; use anyhow::{anyhow, Result}; use serde::Deserialize; use serde_json::{Map, Value}; #[derive(Deserialize)] #[serde(tag = "type")] #[allow(non_camel_case_types)] enum RuleJSON { ALIAS { conten...
{ pub(crate) name: String, rules: Map<String, Value>, #[serde(default)] precedences: Vec<Vec<RuleJSON>>, #[serde(default)] conflicts: Vec<Vec<String>>, #[serde(default)] externals: Vec<RuleJSON>, #[serde(default)] extras: Vec<RuleJSON>, #[serde(default)] inline: Vec<Stri...
GrammarJSON
identifier_name
parse_grammar.rs
use super::grammars::{InputGrammar, PrecedenceEntry, Variable, VariableType}; use super::rules::{Precedence, Rule}; use anyhow::{anyhow, Result}; use serde::Deserialize; use serde_json::{Map, Value}; #[derive(Deserialize)] #[serde(tag = "type")] #[allow(non_camel_case_types)] enum RuleJSON { ALIAS { conten...
"type": "REPEAT1", "content": { "type": "SYMBOL", "name": "statement" } }, "statement": { "type": "STRING", "value": "foo" }...
random_line_split
vec-matching.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 ...
let x = [1, 2, 3]; match x { [a, b, c..] => { assert_eq!(a, 1); assert_eq!(b, 2); let expected: &[_] = &[3]; assert_eq!(c, expected); } } match x { [a.., b, c] => { let expected: &[_] = &[1]; assert_eq!(a, ex...
random_line_split
vec-matching.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() { a(); b(); c(); d(); e(); }
{ let x: &[int] = &[1, 2, 3]; match x { [1, 2] => (), [..] => () } }
identifier_body
vec-matching.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 ...
() { let x: &[int] = &[1, 2, 3]; match x { [1, 2] => (), [..] => () } } pub fn main() { a(); b(); c(); d(); e(); }
e
identifier_name
main.rs
fn main() { println!("Hello, world!"); let mut x: i32 = 5; x = 10; print_num(5); add_num(4, 6); let x1: i32; x1 = add_one(7); let f: fn(i32) -> i32 = add_one; let ff = add_one; let x2 = f(6); let x3 = ff(8); let x_bool = true; let y_bool: bool = false; pri...
; // y: i32 println!("y is {}", y); // Or let y = if x == 5 { 10 } else { 15 }; // y: i32 // Rust provide 3 kinds of iterative activity: loop, while, for. let mut x = 5; // mut x: i32 let mut done = false; // mut done: bool while!done { x += x - 3; println!("x iterative...
{ 15 }
conditional_block
main.rs
fn main() { println!("Hello, world!"); let mut x: i32 = 5; x = 10; print_num(5); add_num(4, 6); let x1: i32; x1 = add_one(7); let f: fn(i32) -> i32 = add_one; let ff = add_one; let x2 = f(6); let x3 = ff(8); let x_bool = true; let y_bool: bool = false; pri...
(x: i32) -> i32 { x }
foo
identifier_name
main.rs
fn main() { println!("Hello, world!"); let mut x: i32 = 5; x = 10; print_num(5); add_num(4, 6); let x1: i32; x1 = add_one(7); let f: fn(i32) -> i32 = add_one; let ff = add_one; let x2 = f(6); let x3 = ff(8); let x_bool = true; let y_bool: bool = false; pri...
fn add_num(x: i32, y: i32){ println!("sum is {}", x + y); } fn add_one(x: i32) -> i32{ x + 1 } fn foo(x: i32) -> i32 { x }
{ println!("x is {}", x); }
identifier_body
main.rs
fn main() { println!("Hello, world!"); let mut x: i32 = 5; x = 10; print_num(5); add_num(4, 6); let x1: i32;
let x2 = f(6); let x3 = ff(8); let x_bool = true; let y_bool: bool = false; println!("x_bool's value: {}", x_bool); let x_char = 'H'; println!("x_char's value: {}", x_char); let a = [1, 2, 3]; //a: [i32; 3] let mut m = [1, 2, 3]; //m: [i32; 3] let aa = [0; 20]; //aa ...
x1 = add_one(7); let f: fn(i32) -> i32 = add_one; let ff = add_one;
random_line_split
if_match.rs
use header::EntityTag; header! { #[doc="`If-Match` header, defined in"] #[doc="[RFC7232](https://tools.ietf.org/html/rfc7232#section-3.1)"] #[doc=""] #[doc="The `If-Match` header field makes the request method conditional on"] #[doc="the recipient origin server either having at least one current"] ...
test_header!( test2, vec![b"\"xyzzy\", \"r2d2xxxx\", \"c3piozzzz\""], Some(HeaderField::Items( vec![EntityTag::new(false, "xyzzy".to_owned()), EntityTag::new(false, "r2d2xxxx".to_owned()), EntityTag::new(false, "c3pioz...
test_header!( test1, vec![b"\"xyzzy\""], Some(HeaderField::Items( vec![EntityTag::new(false, "xyzzy".to_owned())])));
random_line_split
http_loader.rs
// If the URL is a view-source scheme then the scheme data contains the // real URL that should be used for which the source is to be viewed. // Change our existing URL to that and keep note that we are viewing // the source rather than rendering the contents of the URL. let viewing_source = url.sc...
{ let (progress_chan, mut chunk) = { let buf = match read_block(reader) { Ok(ReadResult::Payload(buf)) => buf, _ => vec!(), }; let p = match start_sending_sniffed_opt(start_chan, metadata, classifier, &buf) { Ok(p) => p, _ => return }; ...
identifier_body
http_loader.rs
; use std::boxed::FnBox; use uuid; pub fn factory(resource_mgr_chan: IpcSender<ControlMsg>, devtools_chan: Option<Sender<DevtoolsControlMsg>>, hsts_list: Arc<Mutex<HSTSList>>) -> Box<FnBox(LoadData, LoadConsumer, Arc<MIMEClassifier>) + Send> { box move |load_data, sende...
// See https://bugzilla.mozilla.org/show_bug.cgi?id=401564 and // https://bugzilla.mozilla.org/show_bug.cgi?id=216828. // Only preserve ones which have been explicitly marked as such. if iters == 1 { let mut combined_headers = load_data.headers.clone(); combined_h...
// Avoid automatically preserving request headers when redirects occur.
random_line_split
http_loader.rs
use std::boxed::FnBox; use uuid; pub fn factory(resource_mgr_chan: IpcSender<ControlMsg>, devtools_chan: Option<Sender<DevtoolsControlMsg>>, hsts_list: Arc<Mutex<HSTSList>>) -> Box<FnBox(LoadData, LoadConsumer, Arc<MIMEClassifier>) + Send> { box move |load_data, senders...
(url: Url, err: String, start_chan: LoadConsumer) { let mut metadata: Metadata = Metadata::default(url); metadata.status = None; match start_sending_opt(start_chan, metadata) { Ok(p) => p.send(Done(Err(err))).unwrap(), _ => {} }; } enum ReadResult { Payload(Vec<u8>), EOF, } fn...
send_error
identifier_name
lib.rs
extern crate hyper; extern crate url; extern crate serde; extern crate serde_json; extern crate hyper_native_tls; #[macro_use] extern crate lazy_static; use hyper::client::{Client}; use hyper::header::{ContentType}; use hyper::client::response::{Response}; use hyper::error::Error as HyperError; use url::form_urlencode...
let opt_result = json.get("status"); let result = match opt_result { Some(result) => result, None => return Err(CleverbotError::MissingValue(String::from("status"))), }; match result.as_ref() { "success" => { let json_nick = json.get("n...
}; let mut body = String::new(); try!(response.read_to_string(&mut body)); let json: BTreeMap<String, String> = try!(serde_json::from_str(&body));
random_line_split
lib.rs
extern crate hyper; extern crate url; extern crate serde; extern crate serde_json; extern crate hyper_native_tls; #[macro_use] extern crate lazy_static; use hyper::client::{Client}; use hyper::header::{ContentType}; use hyper::client::response::{Response}; use hyper::error::Error as HyperError; use url::form_urlencode...
} impl From<JsonError> for CleverbotError { fn from(err: JsonError) -> CleverbotError { CleverbotError::Json(err) } } pub struct Cleverbot { user: String, key: String, pub nick: String, } lazy_static! { static ref CLIENT: Client = Client::with_connector(HttpsConnector::new(NativeTlsC...
{ CleverbotError::Std(err) }
identifier_body
lib.rs
extern crate hyper; extern crate url; extern crate serde; extern crate serde_json; extern crate hyper_native_tls; #[macro_use] extern crate lazy_static; use hyper::client::{Client}; use hyper::header::{ContentType}; use hyper::client::response::{Response}; use hyper::error::Error as HyperError; use url::form_urlencode...
(err: JsonError) -> CleverbotError { CleverbotError::Json(err) } } pub struct Cleverbot { user: String, key: String, pub nick: String, } lazy_static! { static ref CLIENT: Client = Client::with_connector(HttpsConnector::new(NativeTlsClient::new().unwrap())); } impl Cleverbot { /// Crea...
from
identifier_name
mod.rs
// Root Module // // This file is part of AEx. // Copyright (C) 2017 Jeffrey Sharp // // AEx is free software: you can redistribute it and/or modify it // under the terms of the GNU General Public License as published // by the Free Software Foundation, either version 3 of the License, // or (at your option) any later ...
pub mod fmt; pub mod io; //pub mod source; pub mod target; //pub mod types;
pub mod ast;
random_line_split
loop-proper-liveness.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { }
main
identifier_name
loop-proper-liveness.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn test3() { let x: i32; // Similarly, the use of variable `x` is unreachable. 'a: loop { x = loop { return }; } println!("{:?}", x); } fn main() { }
{ // In this test the `'a` loop will never terminate thus making the use of `x` unreachable. let x: i32; 'a: loop { x = loop { continue 'a }; } println!("{:?}", x); }
identifier_body
loop-proper-liveness.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 ...
}
} println!("{:?}", x); } fn main() {
random_line_split
tests.rs
use super::rocket; use rocket::local::Client; use rocket::http::Status; fn test(uri: &str, expected: &str) { let client = Client::new(rocket()).unwrap(); let mut res = client.get(uri).dispatch(); assert_eq!(res.body_string(), Some(expected.into())); } fn test_404(uri: &str) { let client = Client::new(...
{ test("/people/7f205202-7ba1-4c39-b2fc-3e630722bf9f", "We found: Lacy"); test("/people/4da34121-bc7d-4fc1-aee6-bf8de0795333", "We found: Bob"); test("/people/ad962969-4e3d-4de7-ac4a-2d86d6d10839", "We found: George"); test("/people/e18b3a5c-488f-4159-a240-2101e0da19fd", "Person not found for U...
identifier_body
tests.rs
use super::rocket; use rocket::local::Client; use rocket::http::Status; fn test(uri: &str, expected: &str) { let client = Client::new(rocket()).unwrap(); let mut res = client.get(uri).dispatch(); assert_eq!(res.body_string(), Some(expected.into())); } fn test_404(uri: &str) {
assert_eq!(res.status(), Status::NotFound); } #[test] fn test_people() { test("/people/7f205202-7ba1-4c39-b2fc-3e630722bf9f", "We found: Lacy"); test("/people/4da34121-bc7d-4fc1-aee6-bf8de0795333", "We found: Bob"); test("/people/ad962969-4e3d-4de7-ac4a-2d86d6d10839", "We found: George"); test("/pe...
let client = Client::new(rocket()).unwrap(); let res = client.get(uri).dispatch();
random_line_split
tests.rs
use super::rocket; use rocket::local::Client; use rocket::http::Status; fn test(uri: &str, expected: &str) { let client = Client::new(rocket()).unwrap(); let mut res = client.get(uri).dispatch(); assert_eq!(res.body_string(), Some(expected.into())); } fn test_404(uri: &str) { let client = Client::new(...
() { test("/people/7f205202-7ba1-4c39-b2fc-3e630722bf9f", "We found: Lacy"); test("/people/4da34121-bc7d-4fc1-aee6-bf8de0795333", "We found: Bob"); test("/people/ad962969-4e3d-4de7-ac4a-2d86d6d10839", "We found: George"); test("/people/e18b3a5c-488f-4159-a240-2101e0da19fd", "Person not found fo...
test_people
identifier_name
function-arguments.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...
() {()}
zzz
identifier_name