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 |
|---|---|---|---|---|
take.rs | use {Buf};
use std::cmp;
/// A `Buf` adapter which limits the bytes read from an underlying buffer.
///
/// This struct is generally created by calling `take()` on `Buf`. See
/// documentation of [`take()`](trait.Buf.html#method.take) for more details.
#[derive(Debug)]
pub struct Take<T> {
inner: T,
limit: us... | <T>(inner: T, limit: usize) -> Take<T> {
Take {
inner: inner,
limit: limit,
}
}
impl<T> Take<T> {
/// Consumes this `Take`, returning the underlying value.
///
/// # Examples
///
/// ```rust
/// use bytes::{Buf, BufMut};
/// use std::io::Cursor;
///
/// let m... | new | identifier_name |
take.rs | use {Buf};
use std::cmp;
/// A `Buf` adapter which limits the bytes read from an underlying buffer.
///
/// This struct is generally created by calling `take()` on `Buf`. See
/// documentation of [`take()`](trait.Buf.html#method.take) for more details.
#[derive(Debug)]
pub struct Take<T> {
inner: T,
limit: us... |
}
| {
assert!(cnt <= self.limit);
self.inner.advance(cnt);
self.limit -= cnt;
} | identifier_body |
take.rs | use {Buf};
use std::cmp;
/// A `Buf` adapter which limits the bytes read from an underlying buffer.
///
/// This struct is generally created by calling `take()` on `Buf`. See
/// documentation of [`take()`](trait.Buf.html#method.take) for more details.
#[derive(Debug)]
pub struct Take<T> {
inner: T,
limit: us... | assert!(cnt <= self.limit);
self.inner.advance(cnt);
self.limit -= cnt;
}
} | random_line_split | |
errs.rs | use std::fmt;
#[derive(Debug)]
pub enum Error {
NoColumn,
InvalidBucket,
InvalidColumnRef,
InvalidColumnMatch,
WrongNumberOfValues(usize, usize),
WrongValueType(usize),
WrongNumberOfMatches(usize, usize),
WrongMatchType(usize),
NothingToMatch,
}
impl fmt::Display for Error {
fn... | ,
Error::WrongNumberOfValues(expected, actual) => {
write!(f, "wrong number of values, expected: {}, actual: {}.", expected, actual)
},
Error::WrongValueType(idx) => {
write!(f, "wrong value type at column index: {}", idx)
},
Er... | {
write!(f, "column type and value does not match in pattern.")
} | conditional_block |
errs.rs | use std::fmt;
#[derive(Debug)]
pub enum Error {
NoColumn,
InvalidBucket,
InvalidColumnRef,
InvalidColumnMatch,
WrongNumberOfValues(usize, usize),
WrongValueType(usize),
WrongNumberOfMatches(usize, usize),
WrongMatchType(usize),
NothingToMatch,
}
impl fmt::Display for Error {
fn... | Error::InvalidBucket => {
write!(f, "bucket does not exist.")
},
Error::InvalidColumnRef => {
write!(f, "column ref is not valid.")
},
Error::InvalidColumnMatch => {
write!(f, "column type and value does not mat... | write!(f, "bucket has no column defined.")
}, | random_line_split |
errs.rs | use std::fmt;
#[derive(Debug)]
pub enum Error {
NoColumn,
InvalidBucket,
InvalidColumnRef,
InvalidColumnMatch,
WrongNumberOfValues(usize, usize),
WrongValueType(usize),
WrongNumberOfMatches(usize, usize),
WrongMatchType(usize),
NothingToMatch,
}
impl fmt::Display for Error {
fn... | Error::WrongNumberOfMatches(expected, actual) => {
write!(f, "wrong number of matches, expected: {}, actual: {}.", expected, actual)
},
Error::WrongMatchType(idx) => {
write!(f, "wrong match type at column index: {}", idx)
},
Er... | {
match *self {
Error::NoColumn => {
write!(f, "bucket has no column defined.")
},
Error::InvalidBucket => {
write!(f, "bucket does not exist.")
},
Error::InvalidColumnRef => {
write!(f, "column ref is n... | identifier_body |
errs.rs | use std::fmt;
#[derive(Debug)]
pub enum Error {
NoColumn,
InvalidBucket,
InvalidColumnRef,
InvalidColumnMatch,
WrongNumberOfValues(usize, usize),
WrongValueType(usize),
WrongNumberOfMatches(usize, usize),
WrongMatchType(usize),
NothingToMatch,
}
impl fmt::Display for Error {
fn... | (&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
Error::NoColumn => {
write!(f, "bucket has no column defined.")
},
Error::InvalidBucket => {
write!(f, "bucket does not exist.")
},
Error::InvalidColumnRef ... | fmt | identifier_name |
then.rs | use core::fmt;
use core::pin::Pin;
use futures_core::future::Future;
use futures_core::ready;
use futures_core::stream::{FusedStream, Stream};
use futures_core::task::{Context, Poll};
#[cfg(feature = "sink")]
use futures_sink::Sink;
use pin_project_lite::pin_project;
pin_project! {
/// Stream for the [`then`](supe... | (&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Then").field("stream", &self.stream).field("future", &self.future).finish()
}
}
impl<St, Fut, F> Then<St, Fut, F>
where
St: Stream,
F: FnMut(St::Item) -> Fut,
{
pub(super) fn new(stream: St, f: F) -> Self {
Self { stre... | fmt | identifier_name |
then.rs | use core::fmt;
use core::pin::Pin;
use futures_core::future::Future;
use futures_core::ready;
use futures_core::stream::{FusedStream, Stream};
use futures_core::task::{Context, Poll};
#[cfg(feature = "sink")]
use futures_sink::Sink;
use pin_project_lite::pin_project;
pin_project! {
/// Stream for the [`then`](supe... |
fn size_hint(&self) -> (usize, Option<usize>) {
let future_len = if self.future.is_some() { 1 } else { 0 };
let (lower, upper) = self.stream.size_hint();
let lower = lower.saturating_add(future_len);
let upper = match upper {
Some(x) => x.checked_add(future_len),
... | {
let mut this = self.project();
Poll::Ready(loop {
if let Some(fut) = this.future.as_mut().as_pin_mut() {
let item = ready!(fut.poll(cx));
this.future.set(None);
break Some(item);
} else if let Some(item) = ready!(this.stream.as_m... | identifier_body |
then.rs | use core::fmt;
use core::pin::Pin;
use futures_core::future::Future;
use futures_core::ready;
use futures_core::stream::{FusedStream, Stream};
use futures_core::task::{Context, Poll};
#[cfg(feature = "sink")]
use futures_sink::Sink;
use pin_project_lite::pin_project;
pin_project! {
/// Stream for the [`then`](supe... | else {
break None;
}
})
}
fn size_hint(&self) -> (usize, Option<usize>) {
let future_len = if self.future.is_some() { 1 } else { 0 };
let (lower, upper) = self.stream.size_hint();
let lower = lower.saturating_add(future_len);
let upper = matc... | {
this.future.set(Some((this.f)(item)));
} | conditional_block |
then.rs | use core::fmt;
use core::pin::Pin;
use futures_core::future::Future;
use futures_core::ready;
use futures_core::stream::{FusedStream, Stream};
use futures_core::task::{Context, Poll};
#[cfg(feature = "sink")]
use futures_sink::Sink;
use pin_project_lite::pin_project;
pin_project! {
/// Stream for the [`then`](supe... | {
type Item = Fut::Output;
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
let mut this = self.project();
Poll::Ready(loop {
if let Some(fut) = this.future.as_mut().as_pin_mut() {
let item = ready!(fut.poll(cx));
... | St: Stream,
F: FnMut(St::Item) -> Fut,
Fut: Future, | random_line_split |
i8.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 ... | use num::strconv;
use option::Option;
use string::String;
pub use core::i8::{BITS, BYTES, MIN, MAX};
int_module!(i8) | #![doc(primitive = "i8")]
use from_str::FromStr;
use num::{ToStrRadix, FromStrRadix}; | random_line_split |
htmlfieldsetelement.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::attr::Attr;
use dom::bindings::codegen::Bindings::HTMLFieldSetElementBinding;
use dom::bindings::codegen:... | ;
impl CollectionFilter for ElementsFilter {
fn filter<'a>(&self, elem: &'a Element, _root: &'a Node) -> bool {
static TAG_NAMES: StaticStringVec = &["button", "fieldset", "input",
"keygen", "object", "output", "select", "textarea"];
TAG_NAMES.iter... | ElementsFilter | identifier_name |
htmlfieldsetelement.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::attr::Attr;
use dom::bindings::codegen::Bindings::HTMLFieldSetElementBinding;
use dom::bindings::codegen:... |
// https://html.spec.whatwg.org/multipage/#dom-cva-validity
fn Validity(&self) -> Root<ValidityState> {
let window = window_from_node(self);
ValidityState::new(window.r())
}
// https://www.whatwg.org/html/#dom-fieldset-disabled
make_bool_getter!(Disabled);
// https://www.what... | {
#[derive(JSTraceable, HeapSizeOf)]
struct ElementsFilter;
impl CollectionFilter for ElementsFilter {
fn filter<'a>(&self, elem: &'a Element, _root: &'a Node) -> bool {
static TAG_NAMES: StaticStringVec = &["button", "fieldset", "input",
"keygen",... | identifier_body |
htmlfieldsetelement.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::attr::Attr;
use dom::bindings::codegen::Bindings::HTMLFieldSetElementBinding;
use dom::bindings::codegen:... | #[dom_struct]
pub struct HTMLFieldSetElement {
htmlelement: HTMLElement
}
impl HTMLFieldSetElementDerived for EventTarget {
fn is_htmlfieldsetelement(&self) -> bool {
*self.type_id() ==
EventTargetTypeId::Node(
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId... | random_line_split | |
pubsub.rs | use futures_lite::stream::StreamExt;
use lapin::{
options::*, publisher_confirm::Confirmation, types::FieldTable, BasicProperties, Connection,
ConnectionProperties, Result,
};
use tracing::info;
fn main() -> Result<()> |
let queue = channel_a
.queue_declare(
"hello",
QueueDeclareOptions::default(),
FieldTable::default(),
)
.await?;
info!(?queue, "Declared queue");
let mut consumer = channel_b
.basic_consume(
... | {
if std::env::var("RUST_LOG").is_err() {
std::env::set_var("RUST_LOG", "info");
}
tracing_subscriber::fmt::init();
let addr = std::env::var("AMQP_ADDR").unwrap_or_else(|_| "amqp://127.0.0.1:5672/%2f".into());
async_global_executor::block_on(async {
let conn = Connection::connect(... | identifier_body |
pubsub.rs | use futures_lite::stream::StreamExt;
use lapin::{
options::*, publisher_confirm::Confirmation, types::FieldTable, BasicProperties, Connection,
ConnectionProperties, Result,
};
use tracing::info;
fn main() -> Result<()> {
if std::env::var("RUST_LOG").is_err() |
tracing_subscriber::fmt::init();
let addr = std::env::var("AMQP_ADDR").unwrap_or_else(|_| "amqp://127.0.0.1:5672/%2f".into());
async_global_executor::block_on(async {
let conn = Connection::connect(
&addr,
ConnectionProperties::default().with_connection_name("pubsub-examp... | {
std::env::set_var("RUST_LOG", "info");
} | conditional_block |
pubsub.rs | use futures_lite::stream::StreamExt;
use lapin::{
options::*, publisher_confirm::Confirmation, types::FieldTable, BasicProperties, Connection,
ConnectionProperties, Result,
};
use tracing::info;
fn main() -> Result<()> {
if std::env::var("RUST_LOG").is_err() {
std::env::set_var("RUST_LOG", "info");... | "my_consumer",
BasicConsumeOptions::default(),
FieldTable::default(),
)
.await?;
async_global_executor::spawn(async move {
info!("will consume");
while let Some(delivery) = consumer.next().await {
let ... | "hello", | random_line_split |
pubsub.rs | use futures_lite::stream::StreamExt;
use lapin::{
options::*, publisher_confirm::Confirmation, types::FieldTable, BasicProperties, Connection,
ConnectionProperties, Result,
};
use tracing::info;
fn | () -> Result<()> {
if std::env::var("RUST_LOG").is_err() {
std::env::set_var("RUST_LOG", "info");
}
tracing_subscriber::fmt::init();
let addr = std::env::var("AMQP_ADDR").unwrap_or_else(|_| "amqp://127.0.0.1:5672/%2f".into());
async_global_executor::block_on(async {
let conn = Con... | main | identifier_name |
private-method.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 ... | how_hungry : int,
}
impl cat {
pub fn play(&mut self) {
self.meows += 1u;
self.nap();
}
}
impl cat {
fn nap(&mut self) { for _ in range(1u, 10u) { } }
}
fn cat(in_x : uint, in_y : int) -> cat {
cat {
meows: in_x,
how_hungry: in_y
}
}
pub fn main() {
let mut ... | // except according to those terms.
struct cat {
priv meows : uint,
| random_line_split |
private-method.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 ... | (in_x : uint, in_y : int) -> cat {
cat {
meows: in_x,
how_hungry: in_y
}
}
pub fn main() {
let mut nyan : cat = cat(52u, 99);
nyan.play();
}
| cat | identifier_name |
inherited_table.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("InheritedTable", inherited=True,... | horizontal: Au(0),
vertical: Au(0),
}
}
impl ToCss for SpecifiedValue {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
try!(self.horizontal.to_css(dest));
try!(dest.write_str(" "));
self.vertical.to_css(dest)
... | }
#[inline]
pub fn get_initial_value() -> computed_value::T {
computed_value::T { | random_line_split |
inherited_table.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("InheritedTable", inherited=True,... |
}
pub fn parse(_: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue,()> {
let mut lengths = [ None, None ];
for i in 0..2 {
match specified::Length::parse_non_negative(input) {
Err(()) => break,
Ok(length) => lengths[i] = Some(length),
... | {
computed_value::T {
horizontal: self.horizontal.to_computed_value(context),
vertical: self.vertical.to_computed_value(context),
}
} | identifier_body |
inherited_table.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("InheritedTable", inherited=True,... | (_: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue,()> {
let mut lengths = [ None, None ];
for i in 0..2 {
match specified::Length::parse_non_negative(input) {
Err(()) => break,
Ok(length) => lengths[i] = Some(length),
}
}
... | parse | identifier_name |
bufferconsumer.rs | use std::f32;
use std::collections::VecDeque;
use std::str::FromStr;
use std::io::Read;
use std::io::Chars;
use super::Error;
use super::util;
pub struct BufferConsumer<B> {
row: usize,
col: usize,
char_queue: VecDeque<char>,
buffer: B, | }
impl<B> BufferConsumer<B>
where B: Read
{
pub fn new(reader: B) -> BufferConsumer<B> {
BufferConsumer {
row: 0,
col: 0,
char_queue: VecDeque::with_capacity(4),
buffer: reader,
tmp_char: None,
}
}
pub fn consume_word(&mut sel... | tmp_char: Option<char>, | random_line_split |
bufferconsumer.rs | use std::f32;
use std::collections::VecDeque;
use std::str::FromStr;
use std::io::Read;
use std::io::Chars;
use super::Error;
use super::util;
pub struct BufferConsumer<B> {
row: usize,
col: usize,
char_queue: VecDeque<char>,
buffer: B,
tmp_char: Option<char>,
}
impl<B> BufferConsumer<B>
where... | (&mut self) -> Result<f32, Error> {
let num: String = try!(self.consume_while(is_numeric));
f32::from_str(&num)
.map_err(|err| {
Error::new(self.row, self.col, format!("Incorrect float value: {}", err))
})
}
pub fn consume_whitespace(&mut self) -> Result<(... | consume_number | identifier_name |
bufferconsumer.rs | use std::f32;
use std::collections::VecDeque;
use std::str::FromStr;
use std::io::Read;
use std::io::Chars;
use super::Error;
use super::util;
pub struct BufferConsumer<B> {
row: usize,
col: usize,
char_queue: VecDeque<char>,
buffer: B,
tmp_char: Option<char>,
}
impl<B> BufferConsumer<B>
where... |
pub fn consume_any_char(&mut self) -> Option<char> {
if self.tmp_char.is_none() {
match self.buffer.next().and_then(|a| a.ok()) {
Some(c) => {
if c == '\n' {
self.row += 1;
self.col = 0;
} e... | {
let mut result = String::new();
loop {
match self.look_next_char() {
Some(c) => {
if !test(c) {
return Ok(result)
}
self.consume_any_char();
result.push(c);
... | identifier_body |
bufferconsumer.rs | use std::f32;
use std::collections::VecDeque;
use std::str::FromStr;
use std::io::Read;
use std::io::Chars;
use super::Error;
use super::util;
pub struct BufferConsumer<B> {
row: usize,
col: usize,
char_queue: VecDeque<char>,
buffer: B,
tmp_char: Option<char>,
}
impl<B> BufferConsumer<B>
where... |
Some(c) => {
Err(self.error_str(format!(
"Expected character `{}` found: `{}`",
expect,
c
)))
}
_ => {
Err(self.error_str(format!(
"Unexpected end of strea... | {
self.consume_any_char();
Ok(())
} | conditional_block |
extension.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 super::WebGLExtensions;
use canvas_traits::webgl::WebGLVersion;
use crate::dom::bindings::reflector::DomObject... | } | Specific(WebGLVersion), | random_line_split |
extension.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 super::WebGLExtensions;
use canvas_traits::webgl::WebGLVersion;
use crate::dom::bindings::reflector::DomObject... | {
/// Extensions written against both WebGL and WebGL2 specs.
All,
/// Extensions writen against a specific WebGL version spec.
Specific(WebGLVersion),
}
| WebGLExtensionSpec | identifier_name |
font_face.rs | (feature = "gecko")]
use crate::properties::longhands::font_language_override;
use crate::shared_lock::{SharedRwLockReadGuard, ToCssWithGuard};
use crate::str::CssStringWriter;
use crate::values::computed::font::FamilyName;
use crate::values::generics::font::FontStyle as GenericFontStyle;
#[cfg(feature = "gecko")]
use ... |
}
}
rule
}
/// A @font-face rule that is known to have font-family and src declarations.
#[cfg(feature = "servo")]
pub struct FontFace<'a>(&'a FontFaceRuleData);
/// A list of effective sources that we send over through IPC to the font cache.
#[cfg(feature = "servo")]
#[derive(Clone, Debug)]
#[cfg_at... | {
let location = error.location;
let error = ContextualParseError::UnsupportedFontFaceDescriptor(slice, error);
context.log_css_error(location, error)
} | conditional_block |
font_face.rs | (feature = "gecko")]
use crate::properties::longhands::font_language_override;
use crate::shared_lock::{SharedRwLockReadGuard, ToCssWithGuard};
use crate::str::CssStringWriter;
use crate::values::computed::font::FamilyName;
use crate::values::generics::font::FontStyle as GenericFontStyle;
#[cfg(feature = "gecko")]
use ... |
}
impl FontStyle {
/// Returns a computed font-style descriptor.
pub fn compute(&self) -> ComputedFontStyleDescriptor {
match *self {
FontStyle::Normal => ComputedFontStyleDescriptor::Normal,
FontStyle::Italic => ComputedFontStyleDescriptor::Italic,
FontStyle::Obliq... | {
match *self {
FontStyle::Normal => dest.write_str("normal"),
FontStyle::Italic => dest.write_str("italic"),
FontStyle::Oblique(ref first, ref second) => {
dest.write_str("oblique")?;
if *first != SpecifiedFontStyle::default_angle() || first !... | identifier_body |
font_face.rs | cfg(feature = "gecko")]
use crate::properties::longhands::font_language_override;
use crate::shared_lock::{SharedRwLockReadGuard, ToCssWithGuard};
use crate::str::CssStringWriter;
use crate::values::computed::font::FamilyName;
use crate::values::generics::font::FontStyle as GenericFontStyle;
#[cfg(feature = "gecko")]
u... | _ => return Err(input.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(name.clone()))),
}
Ok(())
}
}
}
}
impl ToCssWithGuard for FontFaceRuleData {
// Serialization of FontFaceRule is not specced.
fn to_css(&self, _guard: &Shar... | random_line_split | |
font_face.rs | (feature = "gecko")]
use crate::properties::longhands::font_language_override;
use crate::shared_lock::{SharedRwLockReadGuard, ToCssWithGuard};
use crate::str::CssStringWriter;
use crate::values::computed::font::FamilyName;
use crate::values::generics::font::FontStyle as GenericFontStyle;
#[cfg(feature = "gecko")]
use ... | <T: PartialOrd>(a: T, b: T) -> (T, T) {
if a > b {
(b, a)
} else {
(a, b)
}
}
impl FontWeightRange {
/// Returns a computed font-stretch range.
pub fn compute(&self) -> ComputedFontWeightRange {
let (min, max) = sort_range(self.0.compute().0, self.1.compute().0);
Com... | sort_range | identifier_name |
inline.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 ... |
}
}
ast::ItemStatic(_, mutbl, _) => {
if!ast_util::static_has_significant_address(mutbl, item.attrs.as_slice()) {
// Inlined static items use internal linkage when
// possible, so that LLVM will coal... | {
// With multiple compilation units, duplicated code
// is more of a problem. Also, `codegen_units > 1`
// means the user is okay with losing some
// performance.
Some(AvailableE... | conditional_block |
inline.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,b,c,d| astencode::decode_inlined_item(a, b, c, d));
return match csearch_result {
csearch::not_found => {
ccx.external().borrow_mut().insert(fn_id, None);
fn_id
}
csearch::found(ast::IIItem(item)) => {
ccx.external().borrow_mut().insert(fn_i... | {
let _icx = push_ctxt("maybe_instantiate_inline");
match ccx.external().borrow().find(&fn_id) {
Some(&Some(node_id)) => {
// Already inline
debug!("maybe_instantiate_inline({}): already inline as node id {}",
ty::item_path_str(ccx.tcx(), fn_id), node_id);
... | identifier_body |
inline.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 ... | (ccx: &CrateContext, fn_id: ast::DefId)
-> ast::DefId {
let _icx = push_ctxt("maybe_instantiate_inline");
match ccx.external().borrow().find(&fn_id) {
Some(&Some(node_id)) => {
// Already inline
debug!("maybe_instantiate_inline({}): already inline as node id {}",
... | maybe_instantiate_inline | identifier_name |
inline.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 csearch_result =
csearch::maybe_get_item_ast(
ccx.tcx(), fn_id,
|a,b,c,d| astencode::decode_inlined_item(a, b, c, d));
return match csearch_result {
csearch::not_found => {
ccx.external().borrow_mut().insert(fn_id, None);
fn_id... | Some(&None) => {
return fn_id; // Not inlinable
}
None => {
// Not seen yet | random_line_split |
clientrect.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::ClientRectBinding;
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_obje... | (self.right - self.left).abs()
}
pub fn Height(&self) -> f32 {
(self.bottom - self.top).abs()
}
}
impl Reflectable for ClientRect {
fn reflector<'a>(&'a self) -> &'a Reflector {
&self.reflector_
}
fn mut_reflector<'a>(&'a mut self) -> &'a mut Reflector {
&mut s... | random_line_split | |
clientrect.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::ClientRectBinding;
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_obje... |
pub fn Bottom(&self) -> f32 {
self.bottom
}
pub fn Left(&self) -> f32 {
self.left
}
pub fn Right(&self) -> f32 {
self.right
}
pub fn Width(&self) -> f32 {
(self.right - self.left).abs()
}
pub fn Height(&self) -> f32 {
(self.bottom - self.... | {
self.top
} | identifier_body |
clientrect.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::ClientRectBinding;
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_obje... | (&self) -> f32 {
self.right
}
pub fn Width(&self) -> f32 {
(self.right - self.left).abs()
}
pub fn Height(&self) -> f32 {
(self.bottom - self.top).abs()
}
}
impl Reflectable for ClientRect {
fn reflector<'a>(&'a self) -> &'a Reflector {
&self.reflector_
}
... | Right | identifier_name |
build.rs | // Copyright 2021 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
#![deny(warnings)]
// Enable all clippy lints except for many of the pedantic ones. It's a shame this needs to be copied and pasted across crates, but there doesn't appear to be a way to... | .build_server(true)
.compile_with_config(config, &["protos/test.proto"], &["protos"])?;
Ok(())
} |
let config = Config::new();
tonic_build::configure()
.build_client(true) | random_line_split |
build.rs | // Copyright 2021 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
#![deny(warnings)]
// Enable all clippy lints except for many of the pedantic ones. It's a shame this needs to be copied and pasted across crates, but there doesn't appear to be a way to... | () -> Result<(), Box<dyn std::error::Error>> {
use prost_build::Config;
let config = Config::new();
tonic_build::configure()
.build_client(true)
.build_server(true)
.compile_with_config(config, &["protos/test.proto"], &["protos"])?;
Ok(())
}
| main | identifier_name |
build.rs | // Copyright 2021 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
#![deny(warnings)]
// Enable all clippy lints except for many of the pedantic ones. It's a shame this needs to be copied and pasted across crates, but there doesn't appear to be a way to... | {
use prost_build::Config;
let config = Config::new();
tonic_build::configure()
.build_client(true)
.build_server(true)
.compile_with_config(config, &["protos/test.proto"], &["protos"])?;
Ok(())
} | identifier_body | |
program.rs | use ast;
use super::emitter;
impl<'a> emitter::Emitter<'a> {
pub fn emit_program(&mut self) {
self.emit_begin_program();
self.emit_var_declarations();
self.emit_statements();
self.emit_end_program();
}
}
impl<'a> emitter::Emitter<'a> {
fn emit_begin_program(&mut self) {
... | Self::ir(&mut self.ir, 0, "}");
Self::ir(&mut self.ir, 0, "");
}
} | Self::ir(&mut self.ir, 1, "ret i32 0"); | random_line_split |
program.rs | use ast;
use super::emitter;
impl<'a> emitter::Emitter<'a> {
pub fn emit_program(&mut self) {
self.emit_begin_program();
self.emit_var_declarations();
self.emit_statements();
self.emit_end_program();
}
}
impl<'a> emitter::Emitter<'a> {
fn emit_begin_program(&mut self) {
... |
}
| {
Self::ir(&mut self.ir, 1, "; Return.");
Self::ir(&mut self.ir, 1, "ret i32 0");
Self::ir(&mut self.ir, 0, "}");
Self::ir(&mut self.ir, 0, "");
} | identifier_body |
program.rs | use ast;
use super::emitter;
impl<'a> emitter::Emitter<'a> {
pub fn emit_program(&mut self) {
self.emit_begin_program();
self.emit_var_declarations();
self.emit_statements();
self.emit_end_program();
}
}
impl<'a> emitter::Emitter<'a> {
fn | (&mut self) {
Self::ir(&mut self.ir, 0, "; Program entry point.");
Self::ir(&mut self.ir, 0, "define i32 @main() {");
Self::ir(&mut self.ir, 0, "entry:");
}
fn emit_statements(&mut self) {
Self::ir(&mut self.ir, 1, "; Statements.");
for step in self.block.steps.iter() {
... | emit_begin_program | identifier_name |
next_higher.rs | use malachite_base::num::basic::floats::PrimitiveFloat;
use malachite_base::num::float::NiceFloat;
use malachite_base_test_util::generators::primitive_float_gen_var_9;
use std::panic::catch_unwind;
#[allow(clippy::approx_constant)]
#[test]
pub fn test_next_higher() | test::<f32>(0.99999994, 1.0);
test::<f32>(1.0, 1.0000001);
test::<f32>(1.0000001, 1.0000002);
test::<f32>(3.1415925, core::f32::consts::PI);
test::<f32>(core::f32::consts::PI, 3.141593);
test::<f32>(3.141593, 3.1415932);
test::<f32>(10.0, 10.000001);
test::<f32>(f32::MAX_FINITE, f32::POS... | {
fn test<T: PrimitiveFloat>(x: T, out: T) {
assert_eq!(NiceFloat(x.next_higher()), NiceFloat(out));
}
test::<f32>(f32::NEGATIVE_INFINITY, -f32::MAX_FINITE);
test::<f32>(-f32::MAX_FINITE, -3.4028233e38);
test::<f32>(-458.42188, -458.42184);
test::<f32>(-10.0, -9.999999);
test::<f32>(... | identifier_body |
next_higher.rs | use malachite_base::num::basic::floats::PrimitiveFloat;
use malachite_base::num::float::NiceFloat;
use malachite_base_test_util::generators::primitive_float_gen_var_9; | #[allow(clippy::approx_constant)]
#[test]
pub fn test_next_higher() {
fn test<T: PrimitiveFloat>(x: T, out: T) {
assert_eq!(NiceFloat(x.next_higher()), NiceFloat(out));
}
test::<f32>(f32::NEGATIVE_INFINITY, -f32::MAX_FINITE);
test::<f32>(-f32::MAX_FINITE, -3.4028233e38);
test::<f32>(-458.421... | use std::panic::catch_unwind;
| random_line_split |
next_higher.rs | use malachite_base::num::basic::floats::PrimitiveFloat;
use malachite_base::num::float::NiceFloat;
use malachite_base_test_util::generators::primitive_float_gen_var_9;
use std::panic::catch_unwind;
#[allow(clippy::approx_constant)]
#[test]
pub fn | () {
fn test<T: PrimitiveFloat>(x: T, out: T) {
assert_eq!(NiceFloat(x.next_higher()), NiceFloat(out));
}
test::<f32>(f32::NEGATIVE_INFINITY, -f32::MAX_FINITE);
test::<f32>(-f32::MAX_FINITE, -3.4028233e38);
test::<f32>(-458.42188, -458.42184);
test::<f32>(-10.0, -9.999999);
test::<f3... | test_next_higher | identifier_name |
struct-style-enum.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... | // 0b01011001010110010101100101011001 = 1499027801
// 0b0101100101011001 = 22873
// 0b01011001 = 89
let case3 = Case3 { a: 0, b: 6438275382588823897 };
let univariant = TheOnlyCase { a: -1 };
zzz(); // #break
}
fn zzz() {()} | let case2 = Case2 { a: 0, b: 286331153, c: 286331153 };
// 0b0101100101011001010110010101100101011001010110010101100101011001 = 6438275382588823897 | random_line_split |
struct-style-enum.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... | () {
// In order to avoid endianness trouble all of the following test values consist of a single
// repeated byte. This way each interpretation of the union should look the same, no matter if
// this is a big or little endian machine.
// 0b0111110001111100011111000111110001111100011111000111110001111... | main | identifier_name |
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! This module contains traits in script used generically in the rest of Servo.
//! The traits are here instead o... | /// Notifies script that reflow is finished.
ReflowComplete(PipelineId, u32),
/// Notifies script of the viewport.
Viewport(PipelineId, Rect<f32>),
/// Requests that the script task immediately send the constellation the title of a pipeline.
GetTitle(PipelineId),
/// Notifies script task to ... | random_line_split | |
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! This module contains traits in script used generically in the rest of Servo.
//! The traits are here instead o... | {
/// Id of the parent of this new pipeline.
pub containing_pipeline_id: PipelineId,
/// Id of the newly-created pipeline.
pub new_pipeline_id: PipelineId,
/// Id of the new frame associated with this pipeline.
pub subpage_id: SubpageId,
/// Channel for communicating with this new pipeline'... | NewLayoutInfo | identifier_name |
error.rs | //! Error and result type for SMTP clients
use std::{error::Error as StdError, fmt};
use crate::{
transport::smtp::response::{Code, Severity},
BoxError,
};
// Inspired by https://github.com/seanmonstar/reqwest/blob/a8566383168c0ef06c21f38cbc9213af6ff6db31/src/error.rs
/// The Errors that may occur when send... |
/// Returns true if the error is a permanent SMTP error
pub fn is_permanent(&self) -> bool {
matches!(self.inner.kind, Kind::Permanent(_))
}
/// Returns true if the error is caused by a timeout
pub fn is_timeout(&self) -> bool {
let mut source = self.source();
while let S... | {
matches!(self.inner.kind, Kind::Transient(_))
} | identifier_body |
error.rs | //! Error and result type for SMTP clients
use std::{error::Error as StdError, fmt};
use crate::{
transport::smtp::response::{Code, Severity},
BoxError,
};
// Inspired by https://github.com/seanmonstar/reqwest/blob/a8566383168c0ef06c21f38cbc9213af6ff6db31/src/error.rs
/// The Errors that may occur when send... | (&self) -> bool {
matches!(self.inner.kind, Kind::Transient(_))
}
/// Returns true if the error is a permanent SMTP error
pub fn is_permanent(&self) -> bool {
matches!(self.inner.kind, Kind::Permanent(_))
}
/// Returns true if the error is caused by a timeout
pub fn is_timeout(... | is_transient | identifier_name |
error.rs | //! Error and result type for SMTP clients
use std::{error::Error as StdError, fmt};
use crate::{
transport::smtp::response::{Code, Severity},
BoxError,
};
// Inspired by https://github.com/seanmonstar/reqwest/blob/a8566383168c0ef06c21f38cbc9213af6ff6db31/src/error.rs
/// The Errors that may occur when send... | }
pub(crate) fn client<E: Into<BoxError>>(e: E) -> Error {
Error::new(Kind::Client, Some(e))
}
pub(crate) fn network<E: Into<BoxError>>(e: E) -> Error {
Error::new(Kind::Network, Some(e))
}
pub(crate) fn connection<E: Into<BoxError>>(e: E) -> Error {
Error::new(Kind::Connection, Some(e))
}
#[cfg(any(fea... | }
}
pub(crate) fn response<E: Into<BoxError>>(e: E) -> Error {
Error::new(Kind::Response, Some(e)) | random_line_split |
htmllegendelement.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::HTMLLegendElementBinding;
use crate::dom::bindings::codegen::Bindings::... |
}
impl VirtualMethods for HTMLLegendElement {
fn super_type(&self) -> Option<&dyn VirtualMethods> {
Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods)
}
fn bind_to_tree(&self, tree_in_doc: bool) {
if let Some(ref s) = self.super_type() {
s.bind_to_tree(tree_in_doc);
... | {
Node::reflect_node(
Box::new(HTMLLegendElement::new_inherited(
local_name, prefix, document,
)),
document,
HTMLLegendElementBinding::Wrap,
)
} | identifier_body |
htmllegendelement.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::HTMLLegendElementBinding;
use crate::dom::bindings::codegen::Bindings::... | use crate::dom::htmlfieldsetelement::HTMLFieldSetElement;
use crate::dom::htmlformelement::{FormControl, HTMLFormElement};
use crate::dom::node::{Node, UnbindContext};
use crate::dom::virtualmethods::VirtualMethods;
use dom_struct::dom_struct;
use html5ever::{LocalName, Prefix};
#[dom_struct]
pub struct HTMLLegendElem... | use crate::dom::htmlelement::HTMLElement; | random_line_split |
htmllegendelement.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::HTMLLegendElementBinding;
use crate::dom::bindings::codegen::Bindings::... |
self.upcast::<Element>()
.check_ancestors_disabled_state_for_form_control();
}
fn unbind_from_tree(&self, context: &UnbindContext) {
self.super_type().unwrap().unbind_from_tree(context);
let node = self.upcast::<Node>();
let el = self.upcast::<Element>();
i... | {
s.bind_to_tree(tree_in_doc);
} | conditional_block |
htmllegendelement.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::HTMLLegendElementBinding;
use crate::dom::bindings::codegen::Bindings::... | {
htmlelement: HTMLElement,
form_owner: MutNullableDom<HTMLFormElement>,
}
impl HTMLLegendElement {
fn new_inherited(
local_name: LocalName,
prefix: Option<Prefix>,
document: &Document,
) -> HTMLLegendElement {
HTMLLegendElement {
htmlelement: HTMLElement::n... | HTMLLegendElement | identifier_name |
highlighterDemoText.rs | <ATTRIBUTE>#[macro_use]</ATTRIBUTE>
extern crate <CRATE>log</CRATE>;
use std::collections::<STRUCT>HashMap</STRUCT>;
use std::rc::<STRUCT>Rc</STRUCT>;
mod <MODULE>stuff</MODULE>;
pub enum <ENUM>Flag</ENUM> {
<ENUM_VARIANT>Good</ENUM_VARIANT>,
<ENUM_VARIANT>Bad</ENUM_VARIANT>,
<ENUM_VARIANT>Ugly</ENUM_VAR... | }
<MACRO>info!</MACRO>("The program \"{}\" calculates the value {}",
program, <MUT_BINDING>accumulator</MUT_BINDING>);
}
/// Some documentation `with code`
/// # Heading
/// [Rust](https://www.rust-lang.org/)
<ATTRIBUTE>#[cfg(target_os=</ATTRIBUTE>"linux"<ATTRIBUTE>)]</ATTRIBUTE>
unsafe fn <FUNCT... | random_line_split | |
capabilities.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 serde_json::{Map, Value};
use webdriver::capabilities::{BrowserCapabilities, Capabilities};
use webdriver::er... | fn get_platform_name() -> Option<String> {
if cfg!(target_os = "windows") {
Some("windows".to_string())
} else if cfg!(target_os = "linux") {
Some("linux".to_string())
} else if cfg!(target_os = "macos") {
Some("mac".to_string())
} else {
None
}
} | }
| random_line_split |
capabilities.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 serde_json::{Map, Value};
use webdriver::capabilities::{BrowserCapabilities, Capabilities};
use webdriver::er... | {
if cfg!(target_os = "windows") {
Some("windows".to_string())
} else if cfg!(target_os = "linux") {
Some("linux".to_string())
} else if cfg!(target_os = "macos") {
Some("mac".to_string())
} else {
None
}
} | identifier_body | |
capabilities.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 serde_json::{Map, Value};
use webdriver::capabilities::{BrowserCapabilities, Capabilities};
use webdriver::er... | (&mut self, _: &Capabilities) -> WebDriverResult<Option<String>> {
Ok(Some(self.browser_name.clone()))
}
fn browser_version(&mut self, _: &Capabilities) -> WebDriverResult<Option<String>> {
Ok(Some(self.browser_version.clone()))
}
fn compare_browser_version(&mut self, _: &str, _: &str)... | browser_name | identifier_name |
capabilities.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 serde_json::{Map, Value};
use webdriver::capabilities::{BrowserCapabilities, Capabilities};
use webdriver::er... |
}
| {
None
} | conditional_block |
blob.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
//! Support for converting Mononoke data structures into in-memory blobs.
use anyhow::Result;
use blobstore::BlobstoreBytes;
use bytes::By... |
}
pub trait BlobstoreValue: Sized + Send {
type Key;
fn into_blob(self) -> Blob<Self::Key>;
fn from_blob(blob: Blob<Self::Key>) -> Result<Self>;
}
| {
BlobstoreBytes::from_bytes(blob.data)
} | identifier_body |
blob.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
//! Support for converting Mononoke data structures into in-memory blobs.
use anyhow::Result;
use blobstore::BlobstoreBytes;
use bytes::By... | pub type SkeletonManifestBlob = Blob<SkeletonManifestId>;
pub type ContentMetadataBlob = Blob<ContentMetadataId>;
pub type FastlogBatchBlob = Blob<FastlogBatchId>;
pub type RedactionKeyListBlob = Blob<RedactionKeyListId>;
impl<Id> From<Blob<Id>> for BlobstoreBytes {
#[inline]
fn from(blob: Blob<Id>) -> Blobsto... | pub type RawBundle2Blob = Blob<RawBundle2Id>;
pub type FileUnodeBlob = Blob<FileUnodeId>;
pub type ManifestUnodeBlob = Blob<ManifestUnodeId>;
pub type DeletedManifestBlob = Blob<DeletedManifestId>;
pub type FsnodeBlob = Blob<FsnodeId>; | random_line_split |
blob.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
//! Support for converting Mononoke data structures into in-memory blobs.
use anyhow::Result;
use blobstore::BlobstoreBytes;
use bytes::By... | (&self) -> &Id {
&self.id
}
pub fn data(&self) -> &Bytes {
&self.data
}
}
pub type ChangesetBlob = Blob<ChangesetId>;
pub type ContentBlob = Blob<ContentId>;
pub type ContentChunkBlob = Blob<ContentChunkId>;
pub type RawBundle2Blob = Blob<RawBundle2Id>;
pub type FileUnodeBlob = Blob<FileUn... | id | identifier_name |
union_fields.rs | #![allow(
dead_code,
non_snake_case,
non_camel_case_types,
non_upper_case_globals
)]
#[repr(C)]
#[derive(Copy, Clone)]
pub union nsStyleUnion {
pub mInt: ::std::os::raw::c_int, | #[test]
fn bindgen_test_layout_nsStyleUnion() {
assert_eq!(
::std::mem::size_of::<nsStyleUnion>(),
8usize,
concat!("Size of: ", stringify!(nsStyleUnion))
);
assert_eq!(
::std::mem::align_of::<nsStyleUnion>(),
8usize,
concat!("Alignment of ", stringify!(nsStyle... | pub mFloat: f32,
pub mPointer: *mut ::std::os::raw::c_void,
} | random_line_split |
union_fields.rs | #![allow(
dead_code,
non_snake_case,
non_camel_case_types,
non_upper_case_globals
)]
#[repr(C)]
#[derive(Copy, Clone)]
pub union nsStyleUnion {
pub mInt: ::std::os::raw::c_int,
pub mFloat: f32,
pub mPointer: *mut ::std::os::raw::c_void,
}
#[test]
fn bindgen_test_layout_nsStyleUnion() | stringify!(mInt)
)
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<nsStyleUnion>())).mFloat as *const _ as usize
},
0usize,
concat!(
"Offset of field: ",
stringify!(nsStyleUnion),
"::",
stringify!(mFlo... | {
assert_eq!(
::std::mem::size_of::<nsStyleUnion>(),
8usize,
concat!("Size of: ", stringify!(nsStyleUnion))
);
assert_eq!(
::std::mem::align_of::<nsStyleUnion>(),
8usize,
concat!("Alignment of ", stringify!(nsStyleUnion))
);
assert_eq!(
unsafe ... | identifier_body |
union_fields.rs | #![allow(
dead_code,
non_snake_case,
non_camel_case_types,
non_upper_case_globals
)]
#[repr(C)]
#[derive(Copy, Clone)]
pub union nsStyleUnion {
pub mInt: ::std::os::raw::c_int,
pub mFloat: f32,
pub mPointer: *mut ::std::os::raw::c_void,
}
#[test]
fn | () {
assert_eq!(
::std::mem::size_of::<nsStyleUnion>(),
8usize,
concat!("Size of: ", stringify!(nsStyleUnion))
);
assert_eq!(
::std::mem::align_of::<nsStyleUnion>(),
8usize,
concat!("Alignment of ", stringify!(nsStyleUnion))
);
assert_eq!(
unsa... | bindgen_test_layout_nsStyleUnion | identifier_name |
lib.rs | #[macro_use]
extern crate kiss3d;
extern crate nalgebra as na;
use kiss3d::conrod::color::{Color, Colorable};
use kiss3d::conrod::position::{Positionable, Sizeable};
use kiss3d::conrod::widget::{button::Style, Button, Text, Widget};
use kiss3d::conrod::Labelable;
use wasm_bindgen::prelude::*;
use kiss3d::conrod;
use ... | }
// Generate a unique `WidgetId` for each widget.
widget_ids! {
pub struct Ids {
// The scrollable canvas.
canvas,
// The title and introduction widgets.
title,
introduction,
// Shapes.
shapes_canvas,
rounded_rectangle,
shapes_left_col,
... | {
use conrod::position::{Align, Direction, Padding, Position, Relative};
conrod::Theme {
name: "Demo Theme".to_string(),
padding: Padding::none(),
x_position: Position::Relative(Relative::Align(Align::Start), None),
y_position: Position::Relative(Relative::Direction(Direction::Ba... | identifier_body |
lib.rs | #[macro_use]
extern crate kiss3d;
extern crate nalgebra as na;
use kiss3d::conrod::color::{Color, Colorable};
use kiss3d::conrod::position::{Positionable, Sizeable};
use kiss3d::conrod::widget::{button::Style, Button, Text, Widget};
use kiss3d::conrod::Labelable;
use wasm_bindgen::prelude::*;
use kiss3d::conrod;
use ... | (ui: &mut conrod::UiCell, ids: &Ids, app: &mut DemoApp) {
use conrod::{widget, Colorable, Labelable, Positionable, Sizeable, Widget};
use std::iter::once;
const MARGIN: conrod::Scalar = 30.0;
const SHAPE_GAP: conrod::Scalar = 50.0;
const TITLE_SIZE: conrod::FontSize = 42;
const SUBTITLE_SIZE: c... | gui | identifier_name |
lib.rs | #[macro_use]
extern crate kiss3d;
extern crate nalgebra as na;
use kiss3d::conrod::color::{Color, Colorable};
use kiss3d::conrod::position::{Positionable, Sizeable};
use kiss3d::conrod::widget::{button::Style, Button, Text, Widget};
use kiss3d::conrod::Labelable;
use wasm_bindgen::prelude::*;
use kiss3d::conrod;
use ... | )
.mid_right_with_margin_on(ids.canvas, MARGIN)
.align_middle_y_of(ids.button)
.set(ids.toggle, ui)
{
app.ball_color = if is_white {
conrod::color::WHITE
} else {
conrod::color::BLACK
};
}
let ball_x = app.ball_xy[0];
let ball_y = app... | {
conrod::color::LIGHT_CHARCOAL
} | conditional_block |
lib.rs | #[macro_use]
extern crate kiss3d;
extern crate nalgebra as na;
use kiss3d::conrod::color::{Color, Colorable};
use kiss3d::conrod::position::{Positionable, Sizeable};
use kiss3d::conrod::widget::{button::Style, Button, Text, Widget};
use kiss3d::conrod::Labelable;
use wasm_bindgen::prelude::*;
use kiss3d::conrod;
use ... | c: SceneNode,
rot: UnitQuaternion<f32>,
ids: Ids,
app: DemoApp,
}
impl State for AppState {
fn step(&mut self, window: &mut Window) {
// for event in window.conrod_ui().widget_input(self.ids.button).events() {
// console!(log, format!("Found event: {:?}", event))
... |
struct AppState { | random_line_split |
capturing-logging.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 ... | use std::thread;
struct MyWriter(ChanWriter);
impl Logger for MyWriter {
fn log(&mut self, record: &LogRecord) {
let MyWriter(ref mut inner) = *self;
write!(inner, "{}", record.args);
}
}
fn main() {
let (tx, rx) = channel();
let (mut r, w) = (ChanReader::new(rx), ChanWriter::new(tx))... | random_line_split | |
capturing-logging.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 ... | (ChanWriter);
impl Logger for MyWriter {
fn log(&mut self, record: &LogRecord) {
let MyWriter(ref mut inner) = *self;
write!(inner, "{}", record.args);
}
}
fn main() {
let (tx, rx) = channel();
let (mut r, w) = (ChanReader::new(rx), ChanWriter::new(tx));
let _t = thread::scoped(mov... | MyWriter | identifier_name |
packet_encoding.rs | use std::io;
use std::io::Seek;
use std::time;
use quic::packets;
use quic::packets::frames;
use super::format_duration;
const ITERATION_COUNT: usize = 1000000;
const STREAM_DATA_SIZE: usize = 1000;
pub fn run_benchmark() {
println!("packet_encoding: started...");
let mut write = io::Cursor::new(Vec::with_... | offset: (i * STREAM_DATA_SIZE) as u64,
stream_data: stream_data.clone(),
fin: false,
}),
],
},
}
);
packet.encode(&mut write).unwrap();
byt... | payload: packets::PacketPayload {
frames: vec![
frames::Frame::Ping(frames::ping::PingFrame {}),
frames::Frame::Stream(frames::stream::StreamFrame {
stream_id: 1, | random_line_split |
packet_encoding.rs | use std::io;
use std::io::Seek;
use std::time;
use quic::packets;
use quic::packets::frames;
use super::format_duration;
const ITERATION_COUNT: usize = 1000000;
const STREAM_DATA_SIZE: usize = 1000;
pub fn | () {
println!("packet_encoding: started...");
let mut write = io::Cursor::new(Vec::with_capacity(2 * STREAM_DATA_SIZE));
let stream_data = vec![42; STREAM_DATA_SIZE];
let mut bytes_total: usize = 0;
let start = time::Instant::now();
for i in 0..ITERATION_COUNT {
let packet = packets::P... | run_benchmark | identifier_name |
packet_encoding.rs | use std::io;
use std::io::Seek;
use std::time;
use quic::packets;
use quic::packets::frames;
use super::format_duration;
const ITERATION_COUNT: usize = 1000000;
const STREAM_DATA_SIZE: usize = 1000;
pub fn run_benchmark() | packet_number: 0x1234567890ABCDEF,
payload: packets::PacketPayload {
frames: vec![
frames::Frame::Ping(frames::ping::PingFrame {}),
frames::Frame::Stream(frames::stream::StreamFrame {
stream_i... | {
println!("packet_encoding: started...");
let mut write = io::Cursor::new(Vec::with_capacity(2 * STREAM_DATA_SIZE));
let stream_data = vec![42; STREAM_DATA_SIZE];
let mut bytes_total: usize = 0;
let start = time::Instant::now();
for i in 0..ITERATION_COUNT {
let packet = packets::Pack... | identifier_body |
mod.rs | //
// SOS: the Stupid Operating System
// by Eliza Weisman (eliza@elizas.website)
//
// Copyright (c) 2015-2017 Eliza Weisman
// Released under the terms of the MIT license. See `LICENSE` in the root
// directory of this repository for more information.
//
//! Architecture-specific memory management.
use ::{Addr, ... | /// A frame (physical page)
// TODO: consider renaming this to `Frame` (less typing)?
// - eliza, 2/28/2017
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Page!(PAddr) )]
pub struct PhysicalPage { pub number: u64 }
}
impl fmt::Debug for PhysicalPage {
fn fmt(&self, f: &mut fmt::Form... |
macro_attr! { | random_line_split |
mod.rs | //
// SOS: the Stupid Operating System
// by Eliza Weisman (eliza@elizas.website)
//
// Copyright (c) 2015-2017 Eliza Weisman
// Released under the terms of the MIT license. See `LICENSE` in the root
// directory of this repository for more information.
//
//! Architecture-specific memory management.
use ::{Addr, ... |
/// Convert the frame into a raw pointer to the frame's base address
#[inline]
pub unsafe fn as_ptr<T>(&self) -> *const T {
mem::transmute(self.base_addr())
}
/// Convert the frame into a raw mutable pointer to the frame's base address
#[inline]
pub unsafe fn as_mut_ptr<T>(&self) ... | {
PhysicalPage { number: addr.0 >> PAGE_SHIFT }
} | identifier_body |
mod.rs | //
// SOS: the Stupid Operating System
// by Eliza Weisman (eliza@elizas.website)
//
// Copyright (c) 2015-2017 Eliza Weisman
// Released under the terms of the MIT license. See `LICENSE` in the root
// directory of this repository for more information.
//
//! Architecture-specific memory management.
use ::{Addr, ... | <T>(&self) -> *mut T {
*self.base_addr() as *mut u8 as *mut T
}
}
| as_mut_ptr | identifier_name |
resources.rs | // +--------------------------------------------------------------------------+
// | Copyright 2016 Matthew D. Steele <mdsteele@alum.mit.edu> |
// | |
// | This file is part of System Syzygy. |
... |
// ========================================================================= //
| {
let mut file = loader.load(path)?;
ahi::Image::read_all(&mut file)
} | identifier_body |
resources.rs | // +--------------------------------------------------------------------------+
// | Copyright 2016 Matthew D. Steele <mdsteele@alum.mit.edu> |
// | |
// | This file is part of System Syzygy. |
... | pub fn get_font(&mut self, name: &str) -> Rc<Font> {
self.cache.get_font(self.renderer, name)
}
pub fn get_sprites(&mut self, name: &str) -> Vec<Sprite> {
self.cache.get_sprites(self.renderer, name)
}
}
// ========================================================================= //
pu... |
pub fn get_background(&mut self, name: &str) -> Rc<Background> {
self.cache.get_background(self.renderer, name)
}
| random_line_split |
resources.rs | // +--------------------------------------------------------------------------+
// | Copyright 2016 Matthew D. Steele <mdsteele@alum.mit.edu> |
// | |
// | This file is part of System Syzygy. |
... |
let path = PathBuf::from("fonts").join(name).with_extension("ahf");
let ahf = load_ahf_from_file(&self.loader, &path).expect(name);
let font = Rc::new(Font::new(renderer, &ahf));
self.fonts.insert(name.to_string(), font.clone());
font
}
fn get_sprites(
&mut self... | {
println!("Loading font: {}", name);
} | conditional_block |
resources.rs | // +--------------------------------------------------------------------------+
// | Copyright 2016 Matthew D. Steele <mdsteele@alum.mit.edu> |
// | |
// | This file is part of System Syzygy. |
... | (
loader: &ResourceLoader,
path: &Path,
) -> io::Result<Vec<ahi::Image>> {
let mut file = loader.load(path)?;
ahi::Image::read_all(&mut file)
}
// ========================================================================= //
| load_ahi_from_file | identifier_name |
unrooted_must_root.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 syntax::{ast, codemap, visit};
use syntax::attr::AttrMetaMethods;
use rustc::lint::{Context, LintPass, LintArr... | "Warn and report usage of unrooted jsmanaged objects");
/// Lint for ensuring safe usage of unrooted pointers
///
/// This lint (disable with `-A unrooted-must-root`/`#[allow(unrooted_must_root)]`) ensures that `#[must_root]` values are used correctly.
/// "Incorrect" usage includes:
///
/// - Not being... | declare_lint!(UNROOTED_MUST_ROOT, Deny, | random_line_split |
unrooted_must_root.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 syntax::{ast, codemap, visit};
use syntax::attr::AttrMetaMethods;
use rustc::lint::{Context, LintPass, LintArr... |
impl LintPass for UnrootedPass {
fn get_lints(&self) -> LintArray {
lint_array!(UNROOTED_MUST_ROOT)
}
/// All structs containing #[must_root] types must be #[must_root] themselves
fn check_struct_def(&mut self, cx: &Context, def: &ast::StructDef, _i: ast::Ident, _gen: &ast::Generics, id: ast::... | {
match ty.node {
ast::TyVec(ref t) | ast::TyFixedLengthVec(ref t, _) |
ast::TyPtr(ast::MutTy { ty: ref t, ..}) | ast::TyRptr(_, ast::MutTy { ty: ref t, ..}) => lint_unrooted_ty(cx, &**t, warning),
ast::TyPath(..) => {
match cx.tcx.def_map.borrow()[ty.id] {
... | identifier_body |
unrooted_must_root.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 syntax::{ast, codemap, visit};
use syntax::attr::AttrMetaMethods;
use rustc::lint::{Context, LintPass, LintArr... | (&mut self, cx: &Context, kind: visit::FnKind, decl: &ast::FnDecl,
block: &ast::Block, _span: codemap::Span, id: ast::NodeId) {
match kind {
visit::FkItemFn(i, _, _, _) |
visit::FkMethod(i, _, _) if i.as_str() == "new" || i.as_str() == "new_inherited" => {
... | check_fn | identifier_name |
types.rs | //! Types that specify what is contained in a ZIP.
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum System {
Dos = 0,
Unix = 3,
Unknown,
}
impl System {
pub fn from_u8(system: u8) -> System {
use self::System::*;
match system {
0 => Dos,
3 => Unix,
... |
}
impl DateTime {
/// Converts an msdos (u16, u16) pair to a DateTime object
pub fn from_msdos(datepart: u16, timepart: u16) -> DateTime {
let seconds = (timepart & 0b0000000000011111) << 1;
let minutes = (timepart & 0b0000011111100000) >> 5;
let hours = (timepart & 0b1111100000000000)... | {
DateTime {
year: 1980,
month: 1,
day: 1,
hour: 0,
minute: 0,
second: 0,
}
} | identifier_body |
types.rs | //! Types that specify what is contained in a ZIP.
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum System {
Dos = 0,
Unix = 3,
Unknown,
}
impl System {
pub fn from_u8(system: u8) -> System {
use self::System::*;
match system {
0 => Dos,
3 => Unix,
... | {
/// Compatibility of the file attribute information
pub system: System,
/// Specification version
pub version_made_by: u8,
/// True if the file is encrypted.
pub encrypted: bool,
/// Compression method used to store the file
pub compression_method: crate::compression::CompressionMetho... | ZipFileData | identifier_name |
types.rs | //! Types that specify what is contained in a ZIP.
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum System {
Dos = 0,
Unix = 3,
Unknown,
}
impl System {
pub fn from_u8(system: u8) -> System {
use self::System::*;
match system {
0 => Dos,
3 => Unix,
... |
// 2107-12-31 23:59:59
assert!(DateTime::from_time(::time::Tm {
tm_sec: 59,
tm_min: 59,
tm_hour: 23,
tm_mday: 31,
tm_mon: 11, // tm_mon has number range [0, 11]
tm_year: 207, // 2107 - 1900 = 207
..::time::empty_tm()
... | tm_mon: 0, // tm_mon has number range [0, 11]
tm_year: 80, // 1980 - 1900 = 80
..::time::empty_tm()
})
.is_ok()); | random_line_split |
constant.rs | #pragma version(1)
#pragma rs java_package_name(foo)
const float floatTest = 1.99f;
const double doubleTest = 2.05;
const char charTest = -8; | const short shortTest = -16;
const int intTest = -32;
const long longTest = 17179869184l; // 1 << 34
const long long longlongTest = 68719476736l; // 1 << 36
const uchar ucharTest = 8;
const ushort ushortTest = 16;
const uint uintTest = 32;
const ulong ulongTest = 4611686018427387904L;
const int64_t int64_tTest = -1717... | random_line_split | |
stylist.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 cssparser::SourceLocation;
use euclid::TypedSize2D;
use html5ever::LocalName;
use selectors::parser::LocalName... |
#[test]
fn test_stylist_device_accessors() {
let stylist = mock_stylist();
assert_eq!(stylist.device().media_type(), MediaType::Screen);
let mut stylist_mut = mock_stylist();
assert_eq!(stylist_mut.device_mut().media_type(), MediaType::Screen);
}
#[test]
fn test_stylist_rule_tree_accessors() {
le... | {
let device = Device::new(MediaType::Screen, TypedSize2D::new(0f32, 0f32));
Stylist::new(device, QuirksMode::NoQuirks)
} | identifier_body |
stylist.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 cssparser::SourceLocation;
use euclid::TypedSize2D;
use html5ever::LocalName;
use selectors::parser::LocalName... | () {
let (rules_list, _) = get_mock_rules(&["img.foo", "#top", "IMG", "ImG"]);
let check = |i: usize, names: Option<(&str, &str)>| {
assert!(selector_map::get_local_name(rules_list[i][0].selector.iter())
== names.map(|(name, lower_name)| LocalNameSelector {
name: ... | test_get_local_name | identifier_name |
stylist.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 cssparser::SourceLocation;
use euclid::TypedSize2D;
use html5ever::LocalName; | use selectors::parser::LocalName as LocalNameSelector;
use selectors::parser::Selector;
use servo_atoms::Atom;
use style::context::QuirksMode;
use style::media_queries::{Device, MediaType};
use style::properties::{PropertyDeclarationBlock, PropertyDeclaration};
use style::properties::{longhands, Importance};
use style:... | random_line_split | |
radionodelist.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::HTMLInputElementBinding::HTMLInputElementMethods;
use dom::bindings::codegen... |
}
}
// FIXME: This shouldn't need to be implemented here since NodeList (the parent of
// RadioNodeList) implements IndexedGetter.
// https://github.com/servo/servo/issues/5875
//
// https://dom.spec.whatwg.org/#dom-nodelist-item
fn IndexedGetter(&self, index: u32, found: &mut bool... | {
match input.type_() {
atom!("radio") if value == DOMString::from("on") => {
// Step 2
let val = input.Value();
if val.is_empty() || val == value {
input.SetChecked(true);
... | conditional_block |
radionodelist.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::HTMLInputElementBinding::HTMLInputElementMethods;
use dom::bindings::codegen... | use dom::bindings::codegen::Bindings::RadioNodeListBinding::RadioNodeListMethods;
use dom::bindings::global::GlobalRef;
use dom::bindings::inheritance::Castable;
use dom::bindings::js::{JS, Root};
use dom::bindings::reflector::reflect_dom_object;
use dom::htmlinputelement::HTMLInputElement;
use dom::node::Node;
use dom... | use dom::bindings::codegen::Bindings::RadioNodeListBinding; | random_line_split |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.