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
ttf.rs
//! Module for creating text textures. use common::color::Color4; use gl; use sdl2_sys::pixels::{SDL_Color,SDL_PIXELFORMAT_ARGB8888}; use sdl2_sys::surface::SDL_Surface; use sdl2_sys::surface; use std::ffi::CString; use std::path::Path; use yaglw::gl_context::GLContext; use yaglw::texture::Texture2D; #[allow(non_came...
/// dark black #333 #[allow(dead_code)] pub fn dark<'a>(&self, gl: &'a GLContext, txt: &str) -> Texture2D<'a> { self.render(gl, txt, Color4::of_rgba(0x33, 0x33, 0x33, 0xFF)) } /// light black #555 #[allow(dead_code)] pub fn light<'a>(&self, gl: &'a GLContext, txt: &str) -> Texture2D<'a> { self.r...
#[allow(dead_code)] pub fn red<'a>(&self, gl: &'a GLContext, txt: &str) -> Texture2D<'a> { self.render(gl, txt, Color4::of_rgba(0xFF, 0x00, 0x00, 0xFF)) }
random_line_split
ttf.rs
//! Module for creating text textures. use common::color::Color4; use gl; use sdl2_sys::pixels::{SDL_Color,SDL_PIXELFORMAT_ARGB8888}; use sdl2_sys::surface::SDL_Surface; use sdl2_sys::surface; use std::ffi::CString; use std::path::Path; use yaglw::gl_context::GLContext; use yaglw::texture::Texture2D; #[allow(non_came...
} } impl Font { #[allow(missing_docs)] pub fn new(font: &Path, point_size: u32) -> Font { ensure_init(); let c_path = CString::new(font.to_str().unwrap().as_bytes()).unwrap(); let ptr = c_path.as_ptr() as *const i8; let p = unsafe { ffi::TTF_OpenFont(ptr, point_size as ffi::c_int) }; asser...
{ assert_eq!(ffi::TTF_Init(), 0); }
conditional_block
packed-tuple-struct-size.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 ...
{ Bar = 1, Baz = 2 } #[packed] struct S3_Foo(u8, u16, Foo); #[packed] struct S7_Option(f32, u8, u16, Option<@f64>); pub fn main() { assert_eq!(mem::size_of::<S4>(), 4); assert_eq!(mem::size_of::<S5>(), 5); assert_eq!(mem::size_of::<S13_str>(), 13 + mem::size_of::<~str>()); ...
Foo
identifier_name
packed-tuple-struct-size.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 ...
assert_eq!(mem::size_of::<S5>(), 5); assert_eq!(mem::size_of::<S13_str>(), 13 + mem::size_of::<~str>()); assert_eq!(mem::size_of::<S3_Foo>(), 3 + mem::size_of::<Foo>()); assert_eq!(mem::size_of::<S7_Option>(), 7 + mem::size_of::<Option<@f64>>()); }
#[packed] struct S7_Option(f32, u8, u16, Option<@f64>); pub fn main() { assert_eq!(mem::size_of::<S4>(), 4);
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/. */ /// Implementation of Quartz (CoreGraphics) fonts. extern mod core_foundation; extern mod core_graphics; extern m...
let characters: [UniChar, ..1] = [codepoint as UniChar]; let glyphs: [CGGlyph,..1] = [0 as CGGlyph]; let count: CFIndex = 1; let result = self.ctfont.get_glyphs_for_characters(ptr::to_unsafe_ptr(&characters[0]), ptr::to_unsafe_p...
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/. */ /// Implementation of Quartz (CoreGraphics) fonts. extern mod core_foundation; extern mod core_graphics; extern m...
{ data: CFData, } // Noncopyable. impl Drop for FontTable { fn drop(&mut self) {} } impl FontTable { pub fn wrap(data: CFData) -> FontTable { FontTable { data: data } } } impl FontTableMethods for FontTable { fn with_buffer(&self, blk: |*u8, uint|) { blk(self.data.bytes().as_ptr(...
FontTable
identifier_name
lib.rs
// Copyrighttape Technologies LLC. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in...
pub extern crate bloomchain; pub type Bytes = Vec<u8>; pub mod block; pub mod block_number; pub mod block_receipts; pub mod context; pub mod db_indexes; pub mod errors; pub mod filter; pub mod header; pub mod log; pub mod log_blooms; pub mod receipt; pub mod reserved_addresses; pub mod state_proof; pub mod transactio...
extern crate lazy_static; #[macro_use] extern crate cita_logger as logger; extern crate cita_database as cita_db;
random_line_split
xmlhttprequesteventtarget.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::EventHandlerBinding::EventHandlerNonNull; use dom::bindings::codegen::Bindin...
{ XMLHttpRequest, XMLHttpRequestUpload, } #[dom_struct] #[derive(HeapSizeOf)] pub struct XMLHttpRequestEventTarget { eventtarget: EventTarget, } impl XMLHttpRequestEventTarget { pub fn new_inherited(type_id: XMLHttpRequestEventTargetTypeId) -> XMLHttpRequestEventTarget { XMLHttpRequestEventTa...
XMLHttpRequestEventTargetTypeId
identifier_name
xmlhttprequesteventtarget.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::EventHandlerBinding::EventHandlerNonNull; use dom::bindings::codegen::Bindin...
XMLHttpRequest, XMLHttpRequestUpload, } #[dom_struct] #[derive(HeapSizeOf)] pub struct XMLHttpRequestEventTarget { eventtarget: EventTarget, } impl XMLHttpRequestEventTarget { pub fn new_inherited(type_id: XMLHttpRequestEventTargetTypeId) -> XMLHttpRequestEventTarget { XMLHttpRequestEventTarge...
#[derive(JSTraceable, Copy, Clone, PartialEq, HeapSizeOf)] pub enum XMLHttpRequestEventTargetTypeId {
random_line_split
xmlhttprequesteventtarget.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::EventHandlerBinding::EventHandlerNonNull; use dom::bindings::codegen::Bindin...
} impl<'a> XMLHttpRequestEventTargetMethods for &'a XMLHttpRequestEventTarget { event_handler!(loadstart, GetOnloadstart, SetOnloadstart); event_handler!(progress, GetOnprogress, SetOnprogress); event_handler!(abort, GetOnabort, SetOnabort); event_handler!(error, GetOnerror, SetOnerror); event_ha...
{ match *self.type_id() { EventTargetTypeId::XMLHttpRequestEventTarget(_) => true, _ => false } }
identifier_body
escape.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 ...
} _ => {} } } if last < s.len() { fmt.buf.write(pile_o_bits.slice_from(last).as_bytes()); } } }
{ // Because the internet is always right, turns out there's not that many // characters to escape: http://stackoverflow.com/questions/7381974 let Escape(s) = *s; let pile_o_bits = s.as_slice(); let mut last = 0; for (i, ch) in s.bytes().enumerate() { match ch...
identifier_body
escape.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 ...
<'a>(&'a str); impl<'a> fmt::Default for Escape<'a> { fn fmt(s: &Escape<'a>, fmt: &mut fmt::Formatter) { // Because the internet is always right, turns out there's not that many // characters to escape: http://stackoverflow.com/questions/7381974 let Escape(s) = *s; let pile_o_bits =...
Escape
identifier_name
escape.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 ...
impl<'a> fmt::Default for Escape<'a> { fn fmt(s: &Escape<'a>, fmt: &mut fmt::Formatter) { // Because the internet is always right, turns out there's not that many // characters to escape: http://stackoverflow.com/questions/7381974 let Escape(s) = *s; let pile_o_bits = s.as_slice(); ...
/// Wrapper struct which will emit the HTML-escaped version of the contained /// string when passed to a format string. pub struct Escape<'a>(&'a str);
random_line_split
dom.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/. */ //! Types and traits used to access the DOM from style calculation. #![allow(unsafe_code)] #![deny(missing_docs)]...
<T>(pub T); impl<T, I> Iterator for LayoutIterator<T> where T: Iterator<Item=I>, I: NodeInfo, { type Item = I; fn next(&mut self) -> Option<I> { loop { // Filter out nodes that layout should ignore. let n = self.0.next(); if n.is_none() || n.as_ref().un...
LayoutIterator
identifier_name
dom.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/. */ //! Types and traits used to access the DOM from style calculation. #![allow(unsafe_code)] #![deny(missing_docs)]...
/// While doing a reflow, the element at the root has no parent, as far as we're /// concerned. This method returns `None` at the reflow root. fn layout_parent_element(self, reflow_root: OpaqueNode) -> Option<Self> { if self.as_node().opaque() == reflow_root { None } else { ...
random_line_split
dom.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/. */ //! Types and traits used to access the DOM from style calculation. #![allow(unsafe_code)] #![deny(missing_docs)]...
/// A debug id, only useful, mm... for debugging. fn debug_id(self) -> usize; /// Get this node as an element, if it's one. fn as_element(&self) -> Option<Self::ConcreteElement>; /// Whether this node needs to be laid out on viewport size change. fn needs_dirty_on_viewport_size_changed(&self...
{ self.parent_node().and_then(|n| n.as_element()) }
identifier_body
lib.rs
#![feature(type_ascription)] #![feature(static_recursion)] #![allow(dead_code)] #![deny(warnings)] #[macro_use] extern crate log; extern crate env_logger; // macro_rules! debug { // ($($exp:expr),*) => { // if cfg!(debug_assertions) { // println!($($exp),*); // } else {} // }
// macro_rules! bug { ($exp: expr) => { panic!(concat!("internal error: ", $exp, " This is a bug in RustyScheme. Please report it \ at https://github.com/DemiMarie/rusty_scheme/issues")) }; ($exp: expr, $($exps: tt)+) => { panic!(concat!("internal error: ", $exp, " This is a bug in...
// }
random_line_split
lib.rs
#![feature(type_ascription)] #![feature(static_recursion)] #![allow(dead_code)] #![deny(warnings)] #[macro_use] extern crate log; extern crate env_logger; // macro_rules! debug { // ($($exp:expr),*) => { // if cfg!(debug_assertions) { // println!($($exp),*); // } else {} // } // } // macro_rules! bug { ($exp: exp...
() {} }
it_works
identifier_name
lib.rs
#![feature(type_ascription)] #![feature(static_recursion)] #![allow(dead_code)] #![deny(warnings)] #[macro_use] extern crate log; extern crate env_logger; // macro_rules! debug { // ($($exp:expr),*) => { // if cfg!(debug_assertions) { // println!($($exp),*); // } else {} // } // } // macro_rules! bug { ($exp: exp...
}
{}
identifier_body
bin.rs
#[macro_use] extern crate log; use cabot; use std::collections::HashMap; use std::iter::FromIterator; use std::net::{AddrParseError, SocketAddr}; use std::pin::Pin; use async_std; use async_std::fs::{File, OpenOptions}; use async_std::io::{self, Stdout, Write}; use async_std::prelude::*; use async_std::task::Context...
else { let towrite = buf.len(); let mut written = 0; loop { let res = Pin::new(&mut self_.out).poll_write(cx, &buf[written..towrite]); match res { Poll::Ready(Ok(l)) => written += l, _ => {} } ...
{ // the first time write is called, all headers are sent // in the buffer. there is no need to parse it again. if log_enabled!(Info) || self_.verbose { self_.display_headers(&buf); } self_.header_read = true; Poll::Ready(Ok(0)) ...
conditional_block
bin.rs
#[macro_use] extern crate log; use cabot; use std::collections::HashMap; use std::iter::FromIterator; use std::net::{AddrParseError, SocketAddr}; use std::pin::Pin; use async_std; use async_std::fs::{File, OpenOptions}; use async_std::io::{self, Stdout, Write}; use async_std::prelude::*; use async_std::task::Context...
(self: Pin<&mut Self>, _cx: &mut Context) -> Poll<io::Result<()>> { let self_ = Pin::get_mut(self); self_.out.flush(); Poll::Ready(Ok(())) } fn poll_close(self: Pin<&mut Self>, cx: &mut Context) -> Poll<io::Result<()>> { let self_ = Pin::get_mut(self); Pin::new(&mut self...
poll_flush
identifier_name
bin.rs
#[macro_use] extern crate log; use cabot; use std::collections::HashMap; use std::iter::FromIterator; use std::net::{AddrParseError, SocketAddr}; use std::pin::Pin; use async_std; use async_std::fs::{File, OpenOptions}; use async_std::io::{self, Stdout, Write}; use async_std::prelude::*; use async_std::task::Context...
Arg::with_name("FILE") .short("o") .long("output") .takes_value(true) .help("Write to FILE instead of stdout"), ) .arg( Arg::with_name("VERBOSE") .short("v") .long("verbose") ....
) .arg(
random_line_split
local_ptr.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 ...
// XXX: The boundary between the running runtime and the testing runtime // seems to be fuzzy at the moment, and trying to use two different keys // results in disaster. This should not be necessary. #[inline] #[cfg(test)] pub fn maybe_tls_key() -> Option<tls::Key> { unsafe { ::cast::transmute(::realstd::rt::shou...
{ unsafe { // NB: This is a little racy because, while the key is // initalized under a mutex and it's assumed to be initalized // in the Scheduler ctor by any thread that needs to use it, // we are not accessing the key under a mutex. Threads that // are not using the new S...
identifier_body
local_ptr.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 ...
void_ptr as *mut T } pub unsafe fn try_unsafe_borrow<T>() -> Option<*mut T> { match maybe_tls_key() { Some(key) => { let void_ptr = tls::get(key); if void_ptr.is_null() { None } else { Some(void_ptr as *mut T) } } ...
{ rtabort!("thread-local pointer is null. bogus!"); }
conditional_block
local_ptr.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
// except according to those terms. //! Access to a single thread-local pointer. //! //! The runtime will use this for storing ~Task. //! //! XXX: Add runtime checks for usage of inconsistent pointer types. //! and for overwriting an existing pointer. use libc::c_void; use cast; use ptr; use cell::Cell; use option::{...
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed
random_line_split
local_ptr.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 ...
<T>() -> Option<*mut T> { match maybe_tls_key() { Some(key) => { let void_ptr = tls::get(key); if void_ptr.is_null() { None } else { Some(void_ptr as *mut T) } } None => None } } #[inline] fn tls_key() -> tl...
try_unsafe_borrow
identifier_name
constants.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 use crate::file_format::{Constant, SignatureToken}; use move_core_types::account_address::AccountAddress; use proptest::{ arbitrary::any, collection::{btree_set, vec, SizeRange}, strategy::Strategy, }; // A `ConstantPoolGen...
( address_count: impl Into<SizeRange>, byte_array_count: impl Into<SizeRange>, ) -> impl Strategy<Value = Self> { // get unique sets of addresses and vector<U8> (empty vector allowed) ( btree_set(any::<AccountAddress>(), address_count), btree_set(vec(any::<u8>...
strategy
identifier_name
constants.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 use crate::file_format::{Constant, SignatureToken}; use move_core_types::account_address::AccountAddress; use proptest::{ arbitrary::any, collection::{btree_set, vec, SizeRange}, strategy::Strategy, }; // A `ConstantPoolGen...
}) } // Return the `ConstantPool` pub fn constant_pool(self) -> Vec<Constant> { let mut constants = vec![]; for address in self.addresses { constants.push(Constant { type_: SignatureToken::Address, data: address.to_vec(), }...
.prop_map(|(addresses, byte_arrays)| Self { addresses: addresses.into_iter().collect(), byte_arrays: byte_arrays.into_iter().collect(),
random_line_split
constants.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 use crate::file_format::{Constant, SignatureToken}; use move_core_types::account_address::AccountAddress; use proptest::{ arbitrary::any, collection::{btree_set, vec, SizeRange}, strategy::Strategy, }; // A `ConstantPoolGen...
byte_array.push(byte_array.len() as u8); byte_array.reverse(); constants.push(Constant { type_: SignatureToken::Vector(Box::new(SignatureToken::U8)), data: byte_array, }); } constants } }
{ continue; }
conditional_block
free.rs
// Copyleft (ↄ) meh. <meh@schizofreni.co> | http://meh.schizofreni.co // // This file is part of cancer. // // cancer 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 // (a...
/// Create an empty `Cell`. pub fn cell(&self) -> Cell { Cell::empty(self.empty.clone()) } /// Reuse or create a new `Row`. pub fn pop(&mut self, cols: usize) -> Row { match self.inner.pop_front() { Some(mut row) => { row.wrapped = false; row.resize(cols, Cell::empty(self.empty.clone())); for ...
self.empty.clone() }
identifier_body
free.rs
// Copyleft (ↄ) meh. <meh@schizofreni.co> | http://meh.schizofreni.co // // This file is part of cancer. // // cancer 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 // (a...
mut self, cols: usize) -> Row { match self.inner.pop_front() { Some(mut row) => { row.wrapped = false; row.resize(cols, Cell::empty(self.empty.clone())); for cell in row.iter_mut().filter(|c|!c.is_default()) { cell.make_empty(self.empty.clone()); } row } None => { Row { i...
p(&
identifier_name
free.rs
// Copyleft (ↄ) meh. <meh@schizofreni.co> | http://meh.schizofreni.co // // This file is part of cancer. // // cancer 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 // (a...
/// Get the empty `Style`. pub fn style(&self) -> Rc<Style> { self.empty.clone() } /// Create an empty `Cell`. pub fn cell(&self) -> Cell { Cell::empty(self.empty.clone()) } /// Reuse or create a new `Row`. pub fn pop(&mut self, cols: usize) -> Row { match self.inner.pop_front() { Some(mut row) => {...
random_line_split
devtools.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::dom::bindings::codegen::Bindings::CSSStyleDeclarationBinding::CSSStyleDeclarationMethods; use crate::d...
( documents: &Documents, pipeline: PipelineId, marker_types: Vec<TimelineMarkerType>, ) { if let Some(window) = documents.find_window(pipeline) { window.drop_devtools_timeline_markers(marker_types); } } pub fn handle_request_animation_frame(documents: &Documents, id: PipelineId, actor_name:...
handle_drop_timeline_markers
identifier_name
devtools.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::dom::bindings::codegen::Bindings::CSSStyleDeclarationBinding::CSSStyleDeclarationMethods; use crate::d...
EvaluateJSReply::StringValue(String::from(jsstring_to_str(*cx, rval.to_string()))) } else if rval.is_null() { EvaluateJSReply::NullValue } else { assert!(rval.is_object()); rooted!(in(*cx) let obj = rval.to_object()); let class_name = CStr::fr...
{ // global.get_cx() returns a valid `JSContext` pointer, so this is safe. let result = unsafe { let cx = global.get_cx(); let _ac = enter_realm(global); rooted!(in(*cx) let mut rval = UndefinedValue()); global.evaluate_js_on_global_with_result(&eval, rval.handle_mut()); ...
identifier_body
devtools.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::dom::bindings::codegen::Bindings::CSSStyleDeclarationBinding::CSSStyleDeclarationMethods; use crate::d...
} pub fn handle_request_animation_frame(documents: &Documents, id: PipelineId, actor_name: String) { if let Some(doc) = documents.find_document(id) { doc.request_animation_frame(AnimationFrameCallback::DevtoolsFramerateTick { actor_name }); } } pub fn handle_reload(documents: &Documents, id: Pipeline...
{ window.drop_devtools_timeline_markers(marker_types); }
conditional_block
devtools.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::dom::bindings::codegen::Bindings::CSSStyleDeclarationBinding::CSSStyleDeclarationMethods; use crate::d...
reply: IpcSender<Option<NodeInfo>>, ) { let info = documents .find_document(pipeline) .and_then(|document| document.GetDocumentElement()) .map(|element| element.upcast::<Node>().summarize()); reply.send(info).unwrap(); } fn find_node_by_unique_id( documents: &Documents, pipelin...
pub fn handle_get_document_element( documents: &Documents, pipeline: PipelineId,
random_line_split
server.rs
// You have to ctrl-C after running this benchmark, since there is no way to kill // a rust-http server. extern crate http; extern crate hyper; extern crate test; use test::Bencher; use std::io::net::ip::{SocketAddr, Ipv4Addr}; use http::server::Server; use hyper::server::{Request, Response}; static PHRASE: &'stati...
(b: &mut Bencher) { if unsafe {!created_http } { spawn(proc() { HttpServer.serve_forever() }); unsafe { created_http = true } // Mega hack because there is no way to wait for serve_forever to start: std::io::timer::sleep(std::time::duration::Duration::seconds(1)); } let url ...
bench_http
identifier_name
server.rs
// You have to ctrl-C after running this benchmark, since there is no way to kill // a rust-http server. extern crate http; extern crate hyper; extern crate test; use test::Bencher; use std::io::net::ip::{SocketAddr, Ipv4Addr}; use http::server::Server; use hyper::server::{Request, Response}; static PHRASE: &'stati...
#[bench] fn bench_hyper(b: &mut Bencher) { let server = hyper::Server::http(Ipv4Addr(127, 0, 0, 1), 0); let mut listener = server.listen(hyper_handle).unwrap(); let url = hyper::Url::parse(format!("http://{}", listener.socket).as_slice()).unwrap(); b.iter(|| request(url.clone())); listener.close(...
{ let mut res = res.start().unwrap(); res.write(PHRASE).unwrap(); res.end().unwrap(); }
identifier_body
server.rs
// You have to ctrl-C after running this benchmark, since there is no way to kill // a rust-http server. extern crate http; extern crate hyper; extern crate test; use test::Bencher; use std::io::net::ip::{SocketAddr, Ipv4Addr};
fn request(url: hyper::Url) { let req = hyper::client::Request::get(url).unwrap(); req.start().unwrap().send().unwrap().read_to_string().unwrap(); } fn hyper_handle(_: Request, res: Response) { let mut res = res.start().unwrap(); res.write(PHRASE).unwrap(); res.end().unwrap(); } #[bench] fn bench...
use http::server::Server; use hyper::server::{Request, Response}; static PHRASE: &'static [u8] = b"Benchmarking hyper vs others!";
random_line_split
server.rs
// You have to ctrl-C after running this benchmark, since there is no way to kill // a rust-http server. extern crate http; extern crate hyper; extern crate test; use test::Bencher; use std::io::net::ip::{SocketAddr, Ipv4Addr}; use http::server::Server; use hyper::server::{Request, Response}; static PHRASE: &'stati...
let url = hyper::Url::parse("http://localhost:4000").unwrap(); b.iter(|| request(url.clone())); }
{ spawn(proc() { HttpServer.serve_forever() }); unsafe { created_http = true } // Mega hack because there is no way to wait for serve_forever to start: std::io::timer::sleep(std::time::duration::Duration::seconds(1)); }
conditional_block
transcribe.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 ...
} } else { /* repeat */ *r.repeat_idx.last_mut().unwrap() += 1u; r.stack.last_mut().unwrap().idx = 0; match r.stack.last().unwrap().sep.clone() { Some(tk) => { r.cur_tok = tk; /* repeat same span, I guess */ ...
r.repeat_idx.pop(); r.repeat_len.pop();
random_line_split
transcribe.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(t: &TokenTree, r: &TtReader) -> LockstepIterSize { match *t { TtDelimited(_, ref delimed) => { delimed.tts.iter().fold(LisUnconstrained, |size, tt| { size + lockstep_iter_size(tt, r) }) }, TtSequence(_, ref seq) => { seq.tts.iter().fold(Li...
lockstep_iter_size
identifier_name
upgrade_room.rs
//! [POST /_matrix/client/r0/rooms/{roomId}/upgrade](https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-rooms-roomid-upgrade) use ruma_api::ruma_api; use ruma_identifiers::RoomId; ruma_api! { metadata { description: "Upgrades a room to a particular version.", method: POST, ...
}
} error: crate::Error
random_line_split
reserved-prefixes-migration.rs
// check-pass // run-rustfix // compile-flags: -Z unstable-options --edition 2018 #![warn(rust_2021_prefixes_incompatible_syntax)] macro_rules! m2 { ($a:tt $b:tt) => {}; } macro_rules! m3 { ($a:tt $b:tt $c:tt) => {}; } fn main()
macro_rules! quote { (# name = # kind # value) => {}; } quote! { #name = #kind#value //~^ WARNING prefix `kind` is unknown [rust_2021_prefixes_incompatible_syntax] //~| WARNING hard error in Rust 2021 }
{ m2!(z"hey"); //~^ WARNING prefix `z` is unknown [rust_2021_prefixes_incompatible_syntax] //~| WARNING hard error in Rust 2021 m2!(prefix"hey"); //~^ WARNING prefix `prefix` is unknown [rust_2021_prefixes_incompatible_syntax] //~| WARNING hard error in Rust 2021 m3!(hey#123); //~^ WARNI...
identifier_body
reserved-prefixes-migration.rs
// check-pass // run-rustfix // compile-flags: -Z unstable-options --edition 2018 #![warn(rust_2021_prefixes_incompatible_syntax)] macro_rules! m2 { ($a:tt $b:tt) => {}; } macro_rules! m3 { ($a:tt $b:tt $c:tt) => {}; } fn main() { m2!(z"hey"); //~^ WARNING prefix `z` is unknown [rust_2021_prefixes_i...
macro_rules! quote { (# name = # kind # value) => {}; } quote! { #name = #kind#value //~^ WARNING prefix `kind` is unknown [rust_2021_prefixes_incompatible_syntax] //~| WARNING hard error in Rust 2021 }
}
random_line_split
reserved-prefixes-migration.rs
// check-pass // run-rustfix // compile-flags: -Z unstable-options --edition 2018 #![warn(rust_2021_prefixes_incompatible_syntax)] macro_rules! m2 { ($a:tt $b:tt) => {}; } macro_rules! m3 { ($a:tt $b:tt $c:tt) => {}; } fn
() { m2!(z"hey"); //~^ WARNING prefix `z` is unknown [rust_2021_prefixes_incompatible_syntax] //~| WARNING hard error in Rust 2021 m2!(prefix"hey"); //~^ WARNING prefix `prefix` is unknown [rust_2021_prefixes_incompatible_syntax] //~| WARNING hard error in Rust 2021 m3!(hey#123); //~^ WA...
main
identifier_name
closure-reform.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 ...
call_it(proc(s) format!("{}{}", greeting, s)); let greeting = "How's life, ".to_string(); call_it(proc(s: String) -> String { format!("{}{}", greeting, s) }); // Closures call_a_thunk(|| println!("Hello world!")); call_this(|s| println!("{}", s)); call_that(|x, y| *x + *y); ...
format!("{}{}", greeting, s) }); let greeting = "Goodbye ".to_string();
random_line_split
closure-reform.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(f: |&str|:Send) { f("Hello!"); } fn call_that(f: <'a>|&'a int, &'a int| -> int) { let (ten, forty_two) = (10, 42); println!("Your lucky number is {}", f(&ten, &forty_two)); } fn call_cramped(f:||->uint,g:<'a>||->&'a uint) { let number = f(); let other_number = *g(); println!("Ticket {} wins a...
call_this
identifier_name
closure-reform.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 call_a_thunk(f: ||) { f(); } fn call_this(f: |&str|:Send) { f("Hello!"); } fn call_that(f: <'a>|&'a int, &'a int| -> int) { let (ten, forty_two) = (10, 42); println!("Your lucky number is {}", f(&ten, &forty_two)); } fn call_cramped(f:||->uint,g:<'a>||->&'a uint) { let number = f(); let ...
{ println!("{}", f("Fred".to_string())) }
identifier_body
proptest_types.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 use crate::{ account_address::AccountAddress, identifier::Identifier, language_storage::{StructTag, TypeTag}, transaction_argument::TransactionArgument, }; use proptest::{collection::vec, prelude::*}; impl Arbitrary for ...
) .prop_map(|(address, module, name, type_params)| { Struct(StructTag { address, module, name, type_params, }) ...
{ use TypeTag::*; let leaf = prop_oneof![ Just(Bool), Just(U8), Just(U64), Just(U128), Just(Address), Just(Vector(Box::new(Bool))), ]; leaf.prop_recursive( 8, // levels deep 16, // max size ...
identifier_body
proptest_types.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 use crate::{ account_address::AccountAddress, identifier::Identifier, language_storage::{StructTag, TypeTag}, transaction_argument::TransactionArgument, }; use proptest::{collection::vec, prelude::*}; impl Arbitrary for ...
(_args: Self::Parameters) -> Self::Strategy { use TypeTag::*; let leaf = prop_oneof![ Just(Bool), Just(U8), Just(U64), Just(U128), Just(Address), Just(Vector(Box::new(Bool))), ]; leaf.prop_recursive( 8, ...
arbitrary_with
identifier_name
proptest_types.rs
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 use crate::{ account_address::AccountAddress, identifier::Identifier, language_storage::{StructTag, TypeTag}, transaction_argument::TransactionArgument, }; use proptest::{collection::vec, prelude::*}; impl Arbitrary for ...
}) }) }, ) .boxed() } } impl Arbitrary for TransactionArgument { type Parameters = (); fn arbitrary_with(_args: ()) -> Self::Strategy { prop_oneof![ any::<bool>().prop_map(TransactionArgument::Bool), any:...
name, type_params,
random_line_split
serial.rs
use lazy_static::lazy_static; use spin::Mutex; use uart_16550::SerialPort; lazy_static! { pub static ref SERIAL1: Mutex<SerialPort> = { let mut serial_port = unsafe { SerialPort::new(0x3F8) }; serial_port.init(); Mutex::new(serial_port) }; } pub fn print(args: ::core::fmt::Arguments)
/// Prints to the host through the serial interface. #[macro_export] macro_rules! serial_print { ($($arg:tt)*) => { $crate::serial::print(format_args!($($arg)*)); }; } /// Prints to the host through the serial interface, appending a newline. #[macro_export] macro_rules! serial_println { () => ($c...
{ use core::fmt::Write; SERIAL1 .lock() .write_fmt(args) .expect("Printing to serial failed"); }
identifier_body
serial.rs
use lazy_static::lazy_static; use spin::Mutex; use uart_16550::SerialPort; lazy_static! { pub static ref SERIAL1: Mutex<SerialPort> = { let mut serial_port = unsafe { SerialPort::new(0x3F8) }; serial_port.init(); Mutex::new(serial_port) }; } pub fn
(args: ::core::fmt::Arguments) { use core::fmt::Write; SERIAL1 .lock() .write_fmt(args) .expect("Printing to serial failed"); } /// Prints to the host through the serial interface. #[macro_export] macro_rules! serial_print { ($($arg:tt)*) => { $crate::serial::print(format_args!...
print
identifier_name
serial.rs
use lazy_static::lazy_static; use spin::Mutex; use uart_16550::SerialPort;
serial_port.init(); Mutex::new(serial_port) }; } pub fn print(args: ::core::fmt::Arguments) { use core::fmt::Write; SERIAL1 .lock() .write_fmt(args) .expect("Printing to serial failed"); } /// Prints to the host through the serial interface. #[macro_export] macro_rules...
lazy_static! { pub static ref SERIAL1: Mutex<SerialPort> = { let mut serial_port = unsafe { SerialPort::new(0x3F8) };
random_line_split
contacts.rs
use postgres; use ipm::PostgresReqExt; use rustc_serialize::json::ToJson; use time::Timespec; #[derive(ToJson)] pub struct Contact { pub contact_id: i32, pub forename: String, pub surname: String, pub email: String, pub cell: String, pub description: String, pub modified: Timespec } impl Cont...
let rows = stmt.query(&[]).unwrap(); for row in rows { vec.push(Contact { contact_id: row.get(0), forename: row.get(1), surname: row.get(2), email: row.get(3), cell: row.get(4), description: row.g...
let stmt = conn.prepare( "SELECT * FROM contacts" ).unwrap();
random_line_split
contacts.rs
use postgres; use ipm::PostgresReqExt; use rustc_serialize::json::ToJson; use time::Timespec; #[derive(ToJson)] pub struct
{ pub contact_id: i32, pub forename: String, pub surname: String, pub email: String, pub cell: String, pub description: String, pub modified: Timespec } impl Contact { pub fn get_all(req: &PostgresReqExt) -> Vec<Contact> { let mut vec = Vec::new(); let conn = req.db_conn(...
Contact
identifier_name
tests.rs
use super::*; use crate::ffi::OsStr; use crate::mem; use crate::ptr; use crate::sys::cvt; macro_rules! t { ($e:expr) => { match $e { Ok(t) => t, Err(e) => panic!("received error for `{}`: {}", stringify!($e), e), } }; } #[test] #[cfg_attr( any( // See #1423...
() { unsafe { // Test to make sure that a signal mask does not get inherited. let mut cmd = Command::new(OsStr::new("cat")); let mut set = mem::MaybeUninit::<libc::sigset_t>::uninit(); let mut old_set = mem::MaybeUninit::<libc::sigset_t>::uninit(); t!(cvt(sigemptyset(set.as_...
test_process_mask
identifier_name
tests.rs
use super::*; use crate::ffi::OsStr; use crate::mem; use crate::ptr; use crate::sys::cvt; macro_rules! t { ($e:expr) => { match $e { Ok(t) => t, Err(e) => panic!("received error for `{}`: {}", stringify!($e), e), } }; } #[test] #[cfg_attr( any( // See #1423...
t!(cat.wait()); } }
let mut buf = [0; 5]; if let Ok(ret) = stdout_read.read(&mut buf) { assert_eq!(ret, 0); }
random_line_split
tests.rs
use super::*; use crate::ffi::OsStr; use crate::mem; use crate::ptr; use crate::sys::cvt; macro_rules! t { ($e:expr) => { match $e { Ok(t) => t, Err(e) => panic!("received error for `{}`: {}", stringify!($e), e), } }; } #[test] #[cfg_attr( any( // See #1423...
t!(cat.wait()); } }
{ assert_eq!(ret, 0); }
conditional_block
tests.rs
use super::*; use crate::ffi::OsStr; use crate::mem; use crate::ptr; use crate::sys::cvt; macro_rules! t { ($e:expr) => { match $e { Ok(t) => t, Err(e) => panic!("received error for `{}`: {}", stringify!($e), e), } }; } #[test] #[cfg_attr( any( // See #1423...
t!(cvt(libc::kill(cat.id() as libc::pid_t, libc::SIGINT))); // We need to wait until SIGINT is definitely delivered. The // easiest way is to write something to cat, and try to read it // back: if SIGINT is unmasked, it'll get delivered when cat is // next scheduled. let ...
{ unsafe { // Test to make sure that a signal mask does not get inherited. let mut cmd = Command::new(OsStr::new("cat")); let mut set = mem::MaybeUninit::<libc::sigset_t>::uninit(); let mut old_set = mem::MaybeUninit::<libc::sigset_t>::uninit(); t!(cvt(sigemptyset(set.as_mut...
identifier_body
integration_parameters.rs
use na::{self, RealField}; /// Parameters for a time-step of the physics engine. #[derive(Clone)] pub struct IntegrationParameters<N: RealField> { /// The timestep (default: `1.0 / 60.0`) dt: N, /// The inverse of `dt`. inv_dt: N, /// If `true`, the world's `step` method will stop right after resol...
else { self.inv_dt = N::one() / dt } } /// Sets the inverse time-stepping length (i.e. the frequency). /// /// This automatically recompute `self.dt`. #[inline] pub fn set_inv_dt(&mut self, inv_dt: N) { self.inv_dt = inv_dt; if inv_dt == N::zero() { ...
{ self.inv_dt = N::zero() }
conditional_block
integration_parameters.rs
use na::{self, RealField}; /// Parameters for a time-step of the physics engine. #[derive(Clone)] pub struct IntegrationParameters<N: RealField> { /// The timestep (default: `1.0 / 60.0`) dt: N, /// The inverse of `dt`. inv_dt: N, /// If `true`, the world's `step` method will stop right after resol...
} impl<N: RealField> Default for IntegrationParameters<N> { fn default() -> Self { Self::new( na::convert(1.0 / 60.0), na::convert(0.2), na::convert(1.0), na::convert(1.0), na::convert(0.001), na::convert(0.001), na::conve...
{ self.inv_dt = inv_dt; if inv_dt == N::zero() { self.dt = N::zero() } else { self.dt = N::one() / inv_dt } }
identifier_body
integration_parameters.rs
use na::{self, RealField}; /// Parameters for a time-step of the physics engine. #[derive(Clone)] pub struct IntegrationParameters<N: RealField> { /// The timestep (default: `1.0 / 60.0`) dt: N, /// The inverse of `dt`. inv_dt: N, /// If `true`, the world's `step` method will stop right after resol...
inv_dt: if dt == N::zero() { N::zero() } else { N::one() / dt }, erp, warmstart_coeff, restitution_velocity_threshold, allowed_linear_error, allowed_angular_error, max_linear_corre...
IntegrationParameters { t: N::zero(), dt,
random_line_split
integration_parameters.rs
use na::{self, RealField}; /// Parameters for a time-step of the physics engine. #[derive(Clone)] pub struct
<N: RealField> { /// The timestep (default: `1.0 / 60.0`) dt: N, /// The inverse of `dt`. inv_dt: N, /// If `true`, the world's `step` method will stop right after resolving exactly one CCD event (default: `false`). /// This allows the user to take action during a timestep, in-between two CCD ev...
IntegrationParameters
identifier_name
no_method_suggested_traits.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 ...
} impl PubPub for u32 {} impl PubPub for i32 {} } pub mod bar { trait PubPriv { fn method(&self); } } mod qux { pub trait PrivPub { fn method(&self); } } mod quz { trait PrivPriv { fn method(&self); } } mod reexport { pub trait Reexported { fn m...
{}
identifier_body
no_method_suggested_traits.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 ...
(&self) {} fn method3(&self) {} } impl PubPub for u32 {} impl PubPub for i32 {} } pub mod bar { trait PubPriv { fn method(&self); } } mod qux { pub trait PrivPub { fn method(&self); } } mod quz { trait PrivPriv { fn method(&self); } } mod reexport {...
method
identifier_name
no_method_suggested_traits.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
// except according to those terms. pub use reexport::Reexported; pub mod foo { pub trait PubPub { fn method(&self) {} fn method3(&self) {} } impl PubPub for u32 {} impl PubPub for i32 {} } pub mod bar { trait PubPriv { fn method(&self); } } mod qux { pub trait Pr...
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed
random_line_split
serde_json.rs
//! [`ToSql`] and [`FromSql`] implementation for JSON `Value`. use serde_json::Value; use crate::types::{FromSql, FromSqlError, FromSqlResult, ToSql, ToSqlOutput, ValueRef}; use crate::Result; /// Serialize JSON `Value` to text. impl ToSql for Value { #[inline] fn to_sql(&self) -> Result<ToSqlOutput<'_>> { ...
fn checked_memory_handle() -> Result<Connection> { let db = Connection::open_in_memory()?; db.execute_batch("CREATE TABLE foo (t TEXT, b BLOB)")?; Ok(db) } #[test] fn test_json_value() -> Result<()> { let db = checked_memory_handle()?; let json = r#"{"foo": 13, ...
random_line_split
serde_json.rs
//! [`ToSql`] and [`FromSql`] implementation for JSON `Value`. use serde_json::Value; use crate::types::{FromSql, FromSqlError, FromSqlResult, ToSql, ToSqlOutput, ValueRef}; use crate::Result; /// Serialize JSON `Value` to text. impl ToSql for Value { #[inline] fn to_sql(&self) -> Result<ToSqlOutput<'_>> { ...
() -> Result<()> { let db = checked_memory_handle()?; let json = r#"{"foo": 13, "bar": "baz"}"#; let data: serde_json::Value = serde_json::from_str(json).unwrap(); db.execute( "INSERT INTO foo (t, b) VALUES (?,?)", &[&data as &dyn ToSql, &json.as_bytes()], ...
test_json_value
identifier_name
serde_json.rs
//! [`ToSql`] and [`FromSql`] implementation for JSON `Value`. use serde_json::Value; use crate::types::{FromSql, FromSqlError, FromSqlResult, ToSql, ToSqlOutput, ValueRef}; use crate::Result; /// Serialize JSON `Value` to text. impl ToSql for Value { #[inline] fn to_sql(&self) -> Result<ToSqlOutput<'_>> { ...
#[test] fn test_json_value() -> Result<()> { let db = checked_memory_handle()?; let json = r#"{"foo": 13, "bar": "baz"}"#; let data: serde_json::Value = serde_json::from_str(json).unwrap(); db.execute( "INSERT INTO foo (t, b) VALUES (?,?)", &[&data as &...
{ let db = Connection::open_in_memory()?; db.execute_batch("CREATE TABLE foo (t TEXT, b BLOB)")?; Ok(db) }
identifier_body
webglbuffer.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/. */ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl use canvas_traits::{CanvasMsg, CanvasWebGLMsg...
self.is_deleted.set(true); self.renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::DeleteBuffer(self.id))).unwrap(); } } }
Ok(()) } pub fn delete(&self) { if !self.is_deleted.get() {
random_line_split
webglbuffer.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/. */ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl use canvas_traits::{CanvasMsg, CanvasWebGLMsg...
} }
{ self.is_deleted.set(true); self.renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::DeleteBuffer(self.id))).unwrap(); }
conditional_block
webglbuffer.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/. */ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl use canvas_traits::{CanvasMsg, CanvasWebGLMsg...
(&self) -> u32 { self.id } // NB: Only valid buffer targets come here pub fn bind(&self, target: u32) -> WebGLResult<()> { if let Some(previous_target) = self.target.get() { if target!= previous_target { return Err(WebGLError::InvalidOperation); } ...
id
identifier_name
uniq-cc-generic.rs
// Copyright 2012-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-MI...
pub fn main() { let v = empty_pointy(); v.a = p(v); }
{ return @mut Pointy { a : none, d : make_uniq_closure(~"hi") } }
identifier_body
uniq-cc-generic.rs
// Copyright 2012-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-MI...
use std::ptr; enum maybe_pointy { none, p(@mut Pointy), } struct Pointy { a : maybe_pointy, d : ~fn() -> uint, } fn make_uniq_closure<A:Send>(a: A) -> ~fn() -> uint { let result: ~fn() -> uint = || ptr::to_unsafe_ptr(&a) as uint; result } fn empty_pointy() -> @mut Pointy { return @mut Po...
// option. This file may not be copied, modified, or distributed // except according to those terms.
random_line_split
uniq-cc-generic.rs
// Copyright 2012-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-MI...
{ a : maybe_pointy, d : ~fn() -> uint, } fn make_uniq_closure<A:Send>(a: A) -> ~fn() -> uint { let result: ~fn() -> uint = || ptr::to_unsafe_ptr(&a) as uint; result } fn empty_pointy() -> @mut Pointy { return @mut Pointy { a : none, d : make_uniq_closure(~"hi") } } pub fn mai...
Pointy
identifier_name
test_dynamic_repeated_get_set.rs
use protobuf::reflect::FileDescriptor; use protobuf::reflect::ReflectValueBox; use super::test_dynamic_repeated_get_set_pb; fn dynamic_file_descriptor() -> FileDescriptor { FileDescriptor::new_dynamic( test_dynamic_repeated_get_set_pb::file_descriptor() .proto() .clone(), Vec...
do_test_repeated(&test_dynamic_repeated_get_set_pb::file_descriptor()); }
fn dynamic_repeated() {
random_line_split
test_dynamic_repeated_get_set.rs
use protobuf::reflect::FileDescriptor; use protobuf::reflect::ReflectValueBox; use super::test_dynamic_repeated_get_set_pb; fn dynamic_file_descriptor() -> FileDescriptor { FileDescriptor::new_dynamic( test_dynamic_repeated_get_set_pb::file_descriptor() .proto() .clone(), Vec...
() { do_test_repeated(&test_dynamic_repeated_get_set_pb::file_descriptor()); }
dynamic_repeated
identifier_name
test_dynamic_repeated_get_set.rs
use protobuf::reflect::FileDescriptor; use protobuf::reflect::ReflectValueBox; use super::test_dynamic_repeated_get_set_pb; fn dynamic_file_descriptor() -> FileDescriptor { FileDescriptor::new_dynamic( test_dynamic_repeated_get_set_pb::file_descriptor() .proto() .clone(), Vec...
{ do_test_repeated(&test_dynamic_repeated_get_set_pb::file_descriptor()); }
identifier_body
htmlmodelement.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::HTMLModElementBinding; use dom::bindings::codegen::InheritTypes::HTMLModElem...
#[allow(unrooted_must_root)] pub fn new(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> Temporary<HTMLModElement> { let element = HTMLModElement::new_inherited(localName, prefix, document); Node::reflect_node(box element, document, HTMLModElementBinding::Wrap) ...
random_line_split
htmlmodelement.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::HTMLModElementBinding; use dom::bindings::codegen::InheritTypes::HTMLModElem...
{ htmlelement: HTMLElement } impl HTMLModElementDerived for EventTarget { fn is_htmlmodelement(&self) -> bool { *self.type_id() == EventTargetTypeId::Node(NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLModElement))) } } impl HTMLModElement { fn new_inherited(localName: ...
HTMLModElement
identifier_name
htmlmodelement.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::HTMLModElementBinding; use dom::bindings::codegen::InheritTypes::HTMLModElem...
}
{ let element = HTMLModElement::new_inherited(localName, prefix, document); Node::reflect_node(box element, document, HTMLModElementBinding::Wrap) }
identifier_body
mod.rs
//! Parse an ICAL calendar. //! //! Wrap the result of the `PropertyParser` into components. //! //! Each component contains properties (ie: `Property`) or sub-components. //! //! * The `VcardParser` return `IcalCalendar` objects. //! //! # Examples //! //! //! ```toml //! [dependencies.ical] //! version = "0.3.*" //! ...
//! for line in reader { //! println!("{:?}", line); //! } //! ``` pub mod component; // Sys mods. use std::cell::RefCell; use std::io::BufRead; // Internal mods use crate::line::LineReader; use crate::parser::{Component, ParserError}; use crate::property::PropertyParser; /// Reader returning `IcalCalendar` obj...
//! let buf = BufReader::new(File::open("./tests/ressources/ical_input.ics") //! .unwrap()); //! //! let reader = ical::IcalParser::new(buf); //!
random_line_split
mod.rs
//! Parse an ICAL calendar. //! //! Wrap the result of the `PropertyParser` into components. //! //! Each component contains properties (ie: `Property`) or sub-components. //! //! * The `VcardParser` return `IcalCalendar` objects. //! //! # Examples //! //! //! ```toml //! [dependencies.ical] //! version = "0.3.*" //! ...
<B> { line_parser: RefCell<PropertyParser<B>>, } impl<B: BufRead> IcalParser<B> { /// Return a new `IcalParser` from a `Reader`. pub fn new(reader: B) -> IcalParser<B> { let line_reader = LineReader::new(reader); let line_parser = PropertyParser::new(line_reader); IcalParser { ...
IcalParser
identifier_name
mod.rs
//! Parse an ICAL calendar. //! //! Wrap the result of the `PropertyParser` into components. //! //! Each component contains properties (ie: `Property`) or sub-components. //! //! * The `VcardParser` return `IcalCalendar` objects. //! //! # Examples //! //! //! ```toml //! [dependencies.ical] //! version = "0.3.*" //! ...
}
{ match self.check_header() { Ok(res) => { if res == None { return None; } } Err(err) => return Some(Err(err)), }; let mut calendar = component::IcalCalendar::new(); let result = match calendar.parse...
identifier_body
macro-crate-cannot-read-embedded-ident.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 = 0; assert_eq!(3, forged_ident!()); }
identifier_body
macro-crate-cannot-read-embedded-ident.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 ...
// aux-build:macro_crate_test.rs // ignore-stage1 // error-pattern: unknown start of token: \u{0} // Issue #15750 and #15962 : this test is checking that the standard // parser rejects embedded idents. pnkfelix did not want to attempt // to make a test file that itself used the embedded ident input form, // since he ...
random_line_split
macro-crate-cannot-read-embedded-ident.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 = 0; assert_eq!(3, forged_ident!()); }
main
identifier_name
cache.rs
use std::os::raw::c_void; use std::ptr; use std::sync::atomic::{AtomicPtr, Ordering}; use crate::runtime::{Class, Sel, self}; /// Allows storing a `Sel` in a static and lazily loading it. #[doc(hidden)] pub struct CachedSel { ptr: AtomicPtr<c_void> } impl CachedSel { /// Constructs a new `CachedSel`. pub...
}
{ // `Relaxed` should be fine since `objc_getClass` is thread-safe. let ptr = self.ptr.load(Ordering::Relaxed); if ptr.is_null() { let cls = runtime::objc_getClass(name.as_ptr() as *const _); self.ptr.store(cls as *mut _, Ordering::Relaxed); cls.as_ref() ...
identifier_body
cache.rs
use std::os::raw::c_void; use std::ptr; use std::sync::atomic::{AtomicPtr, Ordering}; use crate::runtime::{Class, Sel, self}; /// Allows storing a `Sel` in a static and lazily loading it. #[doc(hidden)] pub struct CachedSel { ptr: AtomicPtr<c_void> } impl CachedSel { /// Constructs a new `CachedSel`. pub...
#[inline(always)] pub unsafe fn get(&self, name: &str) -> Option<&'static Class> { // `Relaxed` should be fine since `objc_getClass` is thread-safe. let ptr = self.ptr.load(Ordering::Relaxed); if ptr.is_null() { let cls = runtime::objc_getClass(name.as_ptr() as *const _); ...
/// Returns the cached class. If no class is yet cached, gets one with /// the given name and stores it.
random_line_split
cache.rs
use std::os::raw::c_void; use std::ptr; use std::sync::atomic::{AtomicPtr, Ordering}; use crate::runtime::{Class, Sel, self}; /// Allows storing a `Sel` in a static and lazily loading it. #[doc(hidden)] pub struct CachedSel { ptr: AtomicPtr<c_void> } impl CachedSel { /// Constructs a new `CachedSel`. pub...
} } /// Allows storing a `Class` reference in a static and lazily loading it. #[doc(hidden)] pub struct CachedClass { ptr: AtomicPtr<Class> } impl CachedClass { /// Constructs a new `CachedClass`. pub const fn new() -> CachedClass { CachedClass { ptr: AtomicPtr::new(ptr::null_mut(...
{ Sel::from_ptr(ptr) }
conditional_block
cache.rs
use std::os::raw::c_void; use std::ptr; use std::sync::atomic::{AtomicPtr, Ordering}; use crate::runtime::{Class, Sel, self}; /// Allows storing a `Sel` in a static and lazily loading it. #[doc(hidden)] pub struct
{ ptr: AtomicPtr<c_void> } impl CachedSel { /// Constructs a new `CachedSel`. pub const fn new() -> CachedSel { CachedSel { ptr: AtomicPtr::new(ptr::null_mut()) } } /// Returns the cached selector. If no selector is yet cached, registers /// one with the given name...
CachedSel
identifier_name
encode.rs
use criterion::*; use std::io::Cursor; fn encode_buffer(c: &mut Criterion) { let buf = (0..32_768).map(|c| (c % 256) as u8).collect::<Vec<u8>>(); let length = buf.len(); let mut output = Vec::with_capacity(32_768 * 102 / 100); let mut group = c.benchmark_group("encode"); group .bench_functio...
(c: &mut Criterion) { let mut group = c.benchmark_group("encode_stream"); group .bench_function("encode_stream 32k", |b| { b.iter(|| { let buf = (0..32_768).map(|c| (c % 256) as u8).collect::<Vec<u8>>(); assert_eq!(32_768, buf.len()); let length...
encode_stream
identifier_name
encode.rs
use criterion::*; use std::io::Cursor; fn encode_buffer(c: &mut Criterion) { let buf = (0..32_768).map(|c| (c % 256) as u8).collect::<Vec<u8>>(); let length = buf.len(); let mut output = Vec::with_capacity(32_768 * 102 / 100); let mut group = c.benchmark_group("encode"); group .bench_functio...
assert_eq!(32_768, buf.len()); let length = buf.len(); let options = yenc::EncodeOptions::new().end(length as u64).begin(1); let output = vec![0; length * 110 / 100]; let mut input_r = Cursor::new(buf); let mut output_r = Cu...
group .bench_function("encode_stream 32k", |b| { b.iter(|| { let buf = (0..32_768).map(|c| (c % 256) as u8).collect::<Vec<u8>>();
random_line_split
encode.rs
use criterion::*; use std::io::Cursor; fn encode_buffer(c: &mut Criterion) { let buf = (0..32_768).map(|c| (c % 256) as u8).collect::<Vec<u8>>(); let length = buf.len(); let mut output = Vec::with_capacity(32_768 * 102 / 100); let mut group = c.benchmark_group("encode"); group .bench_functio...
criterion_group!(benches, encode_buffer, encode_stream); criterion_main!(benches);
{ let mut group = c.benchmark_group("encode_stream"); group .bench_function("encode_stream 32k", |b| { b.iter(|| { let buf = (0..32_768).map(|c| (c % 256) as u8).collect::<Vec<u8>>(); assert_eq!(32_768, buf.len()); let length = buf.len(); ...
identifier_body
atomic.rs
/// Copyright (c) Migrant Coder, 2015 /// All rights reserved. use std::boxed; use std::boxed::Box; use std::mem; use std::num::ToPrimitive; use std::ops::{ Deref, DerefMut }; use std::sync::atomic::{ AtomicPtr, Ordering }; /// A non-owning pointer type that supports tagging and atomic compare and set. pub struct Ta...
(&self) -> u64 { unsafe { mem::transmute(self.value()) } } /// Return the tag value. pub fn get_tag(&self) -> u16 { unsafe { let ptr = self.ptr.load(Ordering::Relaxed); let u64ptr: u64 = mem::transmute(ptr); (u64ptr >> 48).to_u16().unwrap() } } /// Set the tag value. pub fn s...
to_u64
identifier_name
atomic.rs
/// Copyright (c) Migrant Coder, 2015 /// All rights reserved. use std::boxed; use std::boxed::Box; use std::mem; use std::num::ToPrimitive; use std::ops::{ Deref, DerefMut }; use std::sync::atomic::{ AtomicPtr, Ordering }; /// A non-owning pointer type that supports tagging and atomic compare and set. pub struct Ta...
} pub fn is_nil(&self) -> bool { unsafe { mem::transmute(self.get()) == 0u64 } } /// Set the value. pub fn set(&self, ptr: *mut T) { self.ptr.store(ptr, Ordering::Relaxed); } /// Return the untagged pointer value. pub fn get(&self) -> *mut T { unsafe { let ptr = self.ptr.load(Order...
{ let value = self.get(); unsafe { self.set(mem::transmute(0x0u64)); } Some(unsafe { Box::from_raw(value) }) }
conditional_block
atomic.rs
/// Copyright (c) Migrant Coder, 2015 /// All rights reserved. use std::boxed; use std::boxed::Box; use std::mem; use std::num::ToPrimitive; use std::ops::{ Deref, DerefMut }; use std::sync::atomic::{ AtomicPtr, Ordering }; /// A non-owning pointer type that supports tagging and atomic compare and set. pub struct Ta...
} impl<T> Deref for TaggedPtr<T> { type Target = T; fn deref<'a>(&'a self) -> &'a T { unsafe { &*self.get() } } } impl<T> DerefMut for TaggedPtr<T> { fn deref_mut<'a>(&'a mut self) -> &'a mut T { unsafe { & mut *self.get() } } } impl<T> Clone for TaggedPtr<T> { fn clone(&self) -> Self { Tag...
{ self.ptr.load(Ordering::Relaxed) == rhs.ptr.load(Ordering::Relaxed) }
identifier_body
atomic.rs
/// Copyright (c) Migrant Coder, 2015 /// All rights reserved. use std::boxed; use std::boxed::Box; use std::mem; use std::num::ToPrimitive; use std::ops::{ Deref, DerefMut }; use std::sync::atomic::{ AtomicPtr, Ordering }; /// A non-owning pointer type that supports tagging and atomic compare and set. pub struct Ta...
} impl<T> Clone for TaggedPtr<T> { fn clone(&self) -> Self { TaggedPtr::from_raw(self.value()) } } unsafe impl<T> Sync for TaggedPtr<T> {}
unsafe { & mut *self.get() } }
random_line_split