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
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/. */ // Make |cargo bench| work. #![cfg_attr(feature = "unstable", feature(test))] #[macro_use] extern crate bitflags;...
extern crate smallvec; pub mod attr; pub mod bloom; mod builder; pub mod context; pub mod matching; pub mod parser; #[cfg(test)] mod size_of_tests; #[cfg(any(test, feature = "gecko_like_types"))] pub mod gecko_like_types; pub mod sink; mod tree; pub mod visitor; pub use parser::{SelectorImpl, Parser, SelectorList}; p...
extern crate phf; extern crate precomputed_hash; #[cfg(test)] #[macro_use] extern crate size_of_test; extern crate servo_arc;
random_line_split
maschine.rs
// maschine.rs: user-space drivers for native instruments USB HIDs // Copyright (C) 2015 William Light <wrl@illest.net> // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as // published by the Free Software Foundation, either v...
(&mut self, &mut dyn Maschine, encoder_idx: usize, delta: i32) {} fn button_down(&mut self, &mut dyn Maschine, button: MaschineButton) {} fn button_up(&mut self, &mut dyn Maschine, button: MaschineButton) {} }
encoder_step
identifier_name
maschine.rs
// maschine.rs: user-space drivers for native instruments USB HIDs // Copyright (C) 2015 William Light <wrl@illest.net> // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as // published by the Free Software Foundation, either v...
use std::os::unix::io::RawFd; #[derive(Copy,Clone,Debug)] pub enum MaschineButton { Restart, StepLeft, StepRight, Grid, Play, Rec, Erase, Shift, Group, Browse, Sampling, NoteRepeat, Encoder, F1, F2, F3, Control, Nav, NavLeft, NavRight,...
// License along with this program. If not, see // <http://www.gnu.org/licenses/>.
random_line_split
maschine.rs
// maschine.rs: user-space drivers for native instruments USB HIDs // Copyright (C) 2015 William Light <wrl@illest.net> // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as // published by the Free Software Foundation, either v...
fn pad_released(&mut self, &mut dyn Maschine, pad_idx: usize) {} fn encoder_step(&mut self, &mut dyn Maschine, encoder_idx: usize, delta: i32) {} fn button_down(&mut self, &mut dyn Maschine, button: MaschineButton) {} fn button_up(&mut self, &mut dyn Maschine, button: MaschineButton) {} }
{}
identifier_body
fpcs.rs
#[doc = "Register `FPCS` reader"] pub struct R(crate::R<FPCS_SPEC>); impl core::ops::Deref for R { type Target = crate::R<FPCS_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { &self.0 } } impl From<crate::R<FPCS_SPEC>> for R { #[inline(always)] fn from(reader: crate::R<FPCS_SP...
w: &'a mut W, } impl<'a> PCMP_W<'a> { #[doc = r"Writes raw bits to the field"] #[inline(always)] pub unsafe fn bits(self, value: u8) -> &'a mut W { self.w.bits = (self.w.bits &!0x0f) | (value as u32 & 0x0f); self.w } } impl R { #[doc = "Bits 0:3 - Floating Prescaler Shadow Compar...
&self.0 } } #[doc = "Field `PCMP` writer - Floating Prescaler Shadow Compare Value"] pub struct PCMP_W<'a> {
random_line_split
fpcs.rs
#[doc = "Register `FPCS` reader"] pub struct R(crate::R<FPCS_SPEC>); impl core::ops::Deref for R { type Target = crate::R<FPCS_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { &self.0 } } impl From<crate::R<FPCS_SPEC>> for R { #[inline(always)] fn from(reader: crate::R<FPCS_SP...
(&mut self) -> PCMP_W { PCMP_W { w: self } } #[doc = "Writes raw bits to the register."] #[inline(always)] pub unsafe fn bits(&mut self, bits: u32) -> &mut Self { self.0.bits(bits); self } } #[doc = "Floating Prescaler Shadow\n\nThis register you can [`read`](crate::generic::...
pcmp
identifier_name
parser.rs
use std::io::{Read, Cursor}; use FromCursor; use compression::Compression; use frame::frame_response::ResponseBody; use super::*; use types::{from_bytes, UUID_LEN, CStringList}; use types::data_serialization_types::decode_timeuuid; use error; pub fn parse_frame(mut cursor: &mut Read, compressor: &Compression) -> erro...
(frame: Frame) -> error::Result<Frame> { match frame.opcode { Opcode::Error => { frame .get_body() .and_then(|err| match err { ResponseBody::Error(err) => Err(error::Error::Server(err)), _ => unreachable!()...
conver_frame_into_result
identifier_name
parser.rs
use std::io::{Read, Cursor}; use FromCursor;
use types::data_serialization_types::decode_timeuuid; use error; pub fn parse_frame(mut cursor: &mut Read, compressor: &Compression) -> error::Result<Frame> { // TODO: try to use slices instead let mut version_bytes = [0; VERSION_LEN]; let mut flag_bytes = [0; FLAG_LEN]; let mut opcode_bytes = [0; OPCO...
use compression::Compression; use frame::frame_response::ResponseBody; use super::*; use types::{from_bytes, UUID_LEN, CStringList};
random_line_split
parser.rs
use std::io::{Read, Cursor}; use FromCursor; use compression::Compression; use frame::frame_response::ResponseBody; use super::*; use types::{from_bytes, UUID_LEN, CStringList}; use types::data_serialization_types::decode_timeuuid; use error; pub fn parse_frame(mut cursor: &mut Read, compressor: &Compression) -> erro...
let mut body_bytes = Vec::with_capacity(length); unsafe { body_bytes.set_len(length); } try!(cursor.read_exact(&mut body_bytes)); let full_body = if flags.iter().any(|flag| flag == &Flag::Compression) { try!(compressor.decode(body_bytes)) } else { try!(Compression::None...
{ // TODO: try to use slices instead let mut version_bytes = [0; VERSION_LEN]; let mut flag_bytes = [0; FLAG_LEN]; let mut opcode_bytes = [0; OPCODE_LEN]; let mut stream_bytes = [0; STREAM_LEN]; let mut length_bytes = [0; LENGTH_LEN]; // NOTE: order of reads matters try!(cursor.read(&mu...
identifier_body
parser.rs
use std::io::{Read, Cursor}; use FromCursor; use compression::Compression; use frame::frame_response::ResponseBody; use super::*; use types::{from_bytes, UUID_LEN, CStringList}; use types::data_serialization_types::decode_timeuuid; use error; pub fn parse_frame(mut cursor: &mut Read, compressor: &Compression) -> erro...
else { None }; let warnings = if flags.iter().any(|flag| flag == &Flag::Warning) { CStringList::from_cursor(&mut body_cursor)?.into_plain() } else { vec![] }; let mut body = vec![]; try!(body_cursor.read_to_end(&mut body)); let frame = Frame { version: ve...
{ let mut tracing_bytes = Vec::with_capacity(UUID_LEN); unsafe { tracing_bytes.set_len(UUID_LEN); } // TODO: try to use slice instead try!(body_cursor.read_exact(&mut tracing_bytes)); decode_timeuuid(tracing_bytes.as_slice()).ok() }
conditional_block
issue-7573.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 ...
println!("{}", l.local_path); } } pub fn list_database<F>(mut f: F) where F: FnMut(&CrateId) { let stuff = ["foo", "bar"]; for l in &stuff { f(&CrateId::new(*l)); } } pub fn main() { remove_package_from_database(); }
for l in &lines_to_use {
random_line_split
issue-7573.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 ...
(s: &str) -> CrateId { CrateId { local_path: s.to_string(), junk: "wutevs".to_string() } } } pub fn remove_package_from_database() { let mut lines_to_use: Vec<&CrateId> = Vec::new(); let push_id = |installed_id: &CrateId| { lines_to_use.push(installed_id); ...
new
identifier_name
issue-7573.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 ...
pub fn main() { remove_package_from_database(); }
{ let stuff = ["foo", "bar"]; for l in &stuff { f(&CrateId::new(*l)); } }
identifier_body
rewrite_reincarnation.rs
// Copyright 2018 Pierre Talbot // 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 writ...
(&mut self, child: &mut Stmt) { self.loops += 1; self.visit_stmt(child); if!self.rename_mode { self.rename_mode = true; let child_copy = child.clone(); self.visit_stmt(child); let seq = StmtKind::Seq(vec![child.clone(), child_copy]); child.node = seq; self.rename_mode = f...
visit_loop
identifier_name
rewrite_reincarnation.rs
// Copyright 2018 Pierre Talbot // 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 writ...
self.visit_binding(&mut let_stmt.binding); self.visit_stmt(&mut *(let_stmt.body)); if self.rename_mode { self.renamings.pop(); } } fn visit_var(&mut self, var: &mut Variable) { self.rename(var); } }
{ let old = let_stmt.binding.name.clone(); let_stmt.binding.name = self.rename_decl(let_stmt.binding.name.clone()); self.renamings.push((old, let_stmt.binding.name.clone())); }
conditional_block
rewrite_reincarnation.rs
// Copyright 2018 Pierre Talbot // 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 writ...
context: Context, loops: usize, rename_mode: bool, renamings: Vec<(Ident, Ident)> } impl Reincarnation { pub fn new(session: Session, context: Context) -> Self { Reincarnation { session, context, loops: 0, rename_mode: false, renamings: vec![] } } fn rewrite(mut self) -> Env<Context> { let...
struct Reincarnation { session: Session,
random_line_split
rewrite_reincarnation.rs
// Copyright 2018 Pierre Talbot // 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 writ...
} impl VisitorMut<JClass> for Reincarnation { fn visit_loop(&mut self, child: &mut Stmt) { self.loops += 1; self.visit_stmt(child); if!self.rename_mode { self.rename_mode = true; let child_copy = child.clone(); self.visit_stmt(child); let seq = StmtKind::Seq(vec![child.clone(), c...
{ for (old, new) in self.renamings.clone() { if var.len() == 1 && var.first() == old { var.path.fragments[0] = new; } } }
identifier_body
borrowck-uniq-via-lend.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 ...
() { struct F { f: G } struct G { g: H } struct H { h: Box<int> } let mut v = F {f: G {g: H {h: box 3}}}; borrow(v.f.g.h); } fn aliased_imm() { let mut v = box 3i; let _w = &v; borrow(v); } fn aliased_mut() { let mut v = box 3i; let _w = &mut v; borrow(v); //~ ERROR cannot ...
local_recs
identifier_name
borrowck-uniq-via-lend.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 _x = &mut w; borrow(v); } fn aliased_other_reassign() { let mut v = box 3i; let mut w = box 4i; let mut _x = &mut w; _x = &mut v; borrow(v); //~ ERROR cannot borrow `*v` } fn main() { }
} fn aliased_other() { let mut v = box 3i; let mut w = box 4i;
random_line_split
borrowck-uniq-via-lend.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn local_recs() { struct F { f: G } struct G { g: H } struct H { h: Box<int> } let mut v = F {f: G {g: H {h: box 3}}}; borrow(v.f.g.h); } fn aliased_imm() { let mut v = box 3i; let _w = &v; borrow(v); } fn aliased_mut() { let mut v = box 3i; let _w = &mut v; borrow(v); //...
{ struct F { f: Box<int> } let mut v = F {f: box 3}; borrow(v.f); }
identifier_body
comparison_chain.rs
use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::ty::implements_trait; use clippy_utils::{get_trait_def_id, if_sequence, in_constant, is_else_clause, paths, SpanlessEq}; use rustc_hir::{BinOpKind, Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, de...
// We only care about the top-most `if` in the chain if is_else_clause(cx.tcx, expr) { return; } if in_constant(cx, expr.hir_id) { return; } // Check that there exists at least one explicit else condition let (conds, _) = if_sequence(ex...
{ return; }
conditional_block
comparison_chain.rs
use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::ty::implements_trait; use clippy_utils::{get_trait_def_id, if_sequence, in_constant, is_else_clause, paths, SpanlessEq}; use rustc_hir::{BinOpKind, Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, de...
(kind: BinOpKind) -> bool { matches!(kind, BinOpKind::Lt | BinOpKind::Gt | BinOpKind::Eq) }
kind_is_cmp
identifier_name
comparison_chain.rs
use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::ty::implements_trait; use clippy_utils::{get_trait_def_id, if_sequence, in_constant, is_else_clause, paths, SpanlessEq}; use rustc_hir::{BinOpKind, Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, de...
{ matches!(kind, BinOpKind::Lt | BinOpKind::Gt | BinOpKind::Eq) }
identifier_body
comparison_chain.rs
use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::ty::implements_trait; use clippy_utils::{get_trait_def_id, if_sequence, in_constant, is_else_clause, paths, SpanlessEq}; use rustc_hir::{BinOpKind, Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, de...
// We only care about the top-most `if` in the chain if is_else_clause(cx.tcx, expr) { return; } if in_constant(cx, expr.hir_id) { return; } // Check that there exists at least one explicit else condition let (conds, _) = if_sequence(expr...
random_line_split
cell.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...
<'b, T:'b> { // FIXME #12808: strange name to try to avoid interfering with // field accesses of the contained type via Deref _parent: &'b RefCell<T> } #[unsafe_destructor] #[unstable] impl<'b, T> Drop for Ref<'b, T> { fn drop(&mut self) { let borrow = self._parent.borrow.get(); debug_a...
Ref
identifier_name
cell.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...
//! // Recursive call to return the just-cached value. //! // Note that if we had not let the previous borrow //! // of the cache fall out of scope then the subsequent //! // recursive borrow would cause a dynamic task panic. //! // This is the major hazard of using `RefCell`. //...
random_line_split
cell.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...
} /// Copy a `Ref`. /// /// The `RefCell` is already immutably borrowed, so this cannot fail. /// /// A `Clone` implementation would interfere with the widespread /// use of `r.borrow().clone()` to clone the contents of a `RefCell`. #[experimental = "likely to be moved to a method, pending language changes"] pub fn c...
{ unsafe { &*self._parent.value.get() } }
identifier_body
gradient_descent.rs
extern crate sensei_math; use sensei_math::math::Mat; use std::f32; fn dot(v1:&[f32], v2:&[f32]) -> f32 { assert!(v1.len() == v2.len()); //TODO: Do some performance comparisons between this form and a // for loop with an accumulator. v1.iter() .zip(v2.iter()) .map(|(&x,&y)| x*y) .fold(0f32, |sum, ...
}
{ let features = mat! [ [1.0], [2.0], [3.0], [4.0] ]; let labels = vec![1.0,2.0,3.0,4.0]; let expected_gradient = 1.0; let computed_gradient = batch(0.001f32, &features, &labels)[0]; ...
identifier_body
gradient_descent.rs
extern crate sensei_math; use sensei_math::math::Mat; use std::f32; fn dot(v1:&[f32], v2:&[f32]) -> f32 { assert!(v1.len() == v2.len()); //TODO: Do some performance comparisons between this form and a // for loop with an accumulator. v1.iter() .zip(v2.iter()) .map(|(&x,&y)| x*y) .fold(0f32, |sum, ...
() { let features = mat! [ [1.0], [2.0], [3.0], [4.0] ]; let labels = vec![1.0,2.0,3.0,4.0]; let expected_gradient = 1.0; let computed_gradient = batch(0.001f32, &features, &labels)[0]; ...
it_works
identifier_name
gradient_descent.rs
extern crate sensei_math; use sensei_math::math::Mat; use std::f32; fn dot(v1:&[f32], v2:&[f32]) -> f32 { assert!(v1.len() == v2.len()); //TODO: Do some performance comparisons between this form and a // for loop with an accumulator. v1.iter() .zip(v2.iter()) .map(|(&x,&y)| x*y) .fold(0f32, |sum, ...
} if prev_error - cumulative_error < epsilon { break; } prev_error = cumulative_error; cumulative_error = 0.0f32; } weights } #[cfg(test)] mod tests { use super::*; use sensei_math::math::Mat; #[test] fn it_works() { let features = mat! [ [1.0], ...
weights[i] = weights[i] - alpha * error * x[i]; } cumulative_error = cumulative_error + error*error;
random_line_split
gradient_descent.rs
extern crate sensei_math; use sensei_math::math::Mat; use std::f32; fn dot(v1:&[f32], v2:&[f32]) -> f32 { assert!(v1.len() == v2.len()); //TODO: Do some performance comparisons between this form and a // for loop with an accumulator. v1.iter() .zip(v2.iter()) .map(|(&x,&y)| x*y) .fold(0f32, |sum, ...
prev_error = cumulative_error; cumulative_error = 0.0f32; } weights } #[cfg(test)] mod tests { use super::*; use sensei_math::math::Mat; #[test] fn it_works() { let features = mat! [ [1.0], [2.0], [3.0], ...
{ break; }
conditional_block
mod.rs
mod endpoint; mod model; use crate::database::settings::{PRIVACY_ADMIN_ONLY, PRIVACY_EVERYONE, PRIVACY_STAFF_ONLY}; use crate::discord::util::is_staff; use crate::server::endpoint::ban::{get_ban, get_bans, update_ban}; use crate::server::endpoint::captcha::{get_captcha_page, submit_captcha}; use crate::server::endpoin...
None } } } } pub async fn check_authentication( config: &Config, services: &TypeMap, req: &web::HttpRequest, ) -> Result<UserId, HttpResponse> { is_authenticated(config, services, req) .await .ok_or_else(|| HttpResponse::Unauthorized().json("Invali...
{ let token = req .headers() .get(HeaderName::from_static("token")) // optimize into constant? .map(|value| value.to_str()) .map(|result| result.ok()) .flatten()?; let claims = verify_token(&config.server_secret, token)?; let invalid_uuid_service = services.get::<In...
identifier_body
mod.rs
mod endpoint; mod model; use crate::database::settings::{PRIVACY_ADMIN_ONLY, PRIVACY_EVERYONE, PRIVACY_STAFF_ONLY}; use crate::discord::util::is_staff; use crate::server::endpoint::ban::{get_ban, get_bans, update_ban}; use crate::server::endpoint::captcha::{get_captcha_page, submit_captcha}; use crate::server::endpoin...
} pub async fn apply_setting_update_checks( config: &Config, services: &TypeMap, req: &HttpRequest, guild_id: GuildId, ) -> Result<(), HttpResponse> { let user_id = match check_authentication(config, services, req).await { Ok(user_id) => user_id, Err(response) => return Err(respons...
{ Err(HttpResponse::Forbidden() .json("You don't have permissions to change moderator log history!")) }
conditional_block
mod.rs
mod endpoint; mod model; use crate::database::settings::{PRIVACY_ADMIN_ONLY, PRIVACY_EVERYONE, PRIVACY_STAFF_ONLY}; use crate::discord::util::is_staff; use crate::server::endpoint::ban::{get_ban, get_bans, update_ban}; use crate::server::endpoint::captcha::{get_captcha_page, submit_captcha}; use crate::server::endpoin...
{ #[serde(rename = "userId")] user_id: String, uuid: Uuid, exp: u64, } fn verify_token(secret: &str, token: &str) -> Option<JwtClaims> { match decode::<JwtClaims>( token, &DecodingKey::from_secret(secret.as_bytes()), &VALIDATION, ) { Ok(data) => Some(data.claims...
JwtClaims
identifier_name
mod.rs
mod endpoint; mod model; use crate::database::settings::{PRIVACY_ADMIN_ONLY, PRIVACY_EVERYONE, PRIVACY_STAFF_ONLY}; use crate::discord::util::is_staff; use crate::server::endpoint::ban::{get_ban, get_bans, update_ban}; use crate::server::endpoint::captcha::{get_captcha_page, submit_captcha}; use crate::server::endpoin...
}; if let Some(response) = check_authorization_to_view_private_endpoint(services, guild_id, permissions, endpoint_kind) .await { return Err(response); } Ok(()) } pub async fn apply_mod_log_update_checks( config: &Config, services: &TypeMap, req: &HttpRequest...
}; let (_, permissions) = match check_guild_endpoint(services, guild_id, user_id).await { Ok((member, permissions)) => (member, permissions), Err(response) => return Err(response),
random_line_split
debug.rs
use alloc::boxed::Box; use collections::string::String; use scheduler::context::{context_switch, context_i, contexts_ptr}; use scheduler; use schemes::{KScheme, Resource, Url}; use syscall::handle; /// A debug resource pub struct DebugResource { pub scheme: *mut DebugScheme, pub command: String, pub li...
fn sync(&mut self) -> bool { true } } pub struct DebugScheme { pub context: usize, } impl DebugScheme { pub fn new() -> Box<Self> { box DebugScheme { context: 0 } } } impl KScheme for DebugScheme { fn scheme(&self) -> &str { "debug" } fn open(&mut self, _: &...
{ for byte in buf { unsafe { handle::do_sys_debug(*byte); } } return Some(buf.len()); }
identifier_body
debug.rs
use alloc::boxed::Box; use collections::string::String; use scheduler::context::{context_switch, context_i, contexts_ptr}; use scheduler; use schemes::{KScheme, Resource, Url}; use syscall::handle; /// A debug resource pub struct DebugResource { pub scheme: *mut DebugScheme, pub command: String, pub li...
let mut i = 0; while i < buf.len() &&! self.command.is_empty() { buf[i] = unsafe { self.command.as_mut_vec().remove(0) }; i += 1; } if i > 0 && self.command.is_empty() { self.line_toggle = true; } Some(i) } fn write(&mut self...
} // TODO: Unicode
random_line_split
debug.rs
use alloc::boxed::Box; use collections::string::String; use scheduler::context::{context_switch, context_i, contexts_ptr}; use scheduler; use schemes::{KScheme, Resource, Url}; use syscall::handle; /// A debug resource pub struct DebugResource { pub scheme: *mut DebugScheme, pub command: String, pub li...
Some(i) } fn write(&mut self, buf: &[u8]) -> Option<usize> { for byte in buf { unsafe { handle::do_sys_debug(*byte); } } return Some(buf.len()); } fn sync(&mut self) -> bool { true } } pub struct DebugScheme { p...
{ self.line_toggle = true; }
conditional_block
debug.rs
use alloc::boxed::Box; use collections::string::String; use scheduler::context::{context_switch, context_i, contexts_ptr}; use scheduler; use schemes::{KScheme, Resource, Url}; use syscall::handle; /// A debug resource pub struct DebugResource { pub scheme: *mut DebugScheme, pub command: String, pub li...
(&mut self) -> bool { true } } pub struct DebugScheme { pub context: usize, } impl DebugScheme { pub fn new() -> Box<Self> { box DebugScheme { context: 0 } } } impl KScheme for DebugScheme { fn scheme(&self) -> &str { "debug" } fn open(&mut self, _: &Url, _: usize...
sync
identifier_name
filemanager_thread.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use crate::create_embedder_proxy; use embedder_traits::FilterPattern; use ipc_channel::ipc; use net::filemanager_t...
, } } } }
{ assert!( false, "Get unexpected response after deleting the id: {:?}", other ); }
conditional_block
filemanager_thread.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use crate::create_embedder_proxy; use embedder_traits::FilterPattern; use ipc_channel::ipc; use net::filemanager_t...
() { let filemanager = FileManager::new(create_embedder_proxy()); PREFS.set( "dom.testing.htmlinputelement.select_files.enabled", PrefValue::Boolean(true), ); // Try to open a dummy file "components/net/tests/test.jpeg" in tree let mut handler = File::open("tests/test.jpeg").expect(...
test_filemanager
identifier_name
filemanager_thread.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use crate::create_embedder_proxy; use embedder_traits::FilterPattern; use ipc_channel::ipc; use net::filemanager_t...
bytes.append(&mut bytes_in); }, ReadFileProgress::EOF => { break; }, } } assert_eq!(test_file_content, bytes, "Read content differs"); ...
random_line_split
filemanager_thread.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use crate::create_embedder_proxy; use embedder_traits::FilterPattern; use ipc_channel::ipc; use net::filemanager_t...
let (tx, rx) = ipc::channel().unwrap(); filemanager.handle(FileManagerThreadMsg::SelectFile( patterns.clone(), tx, origin.clone(), Some("tests/test.jpeg".to_string()), )); let selected = rx .recv() .expect("Broken chan...
{ let filemanager = FileManager::new(create_embedder_proxy()); PREFS.set( "dom.testing.htmlinputelement.select_files.enabled", PrefValue::Boolean(true), ); // Try to open a dummy file "components/net/tests/test.jpeg" in tree let mut handler = File::open("tests/test.jpeg").expect("te...
identifier_body
tree_iter.rs
// Copyright 2013-2015, The Rust-GNOME Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT> use ffi; use std; pub struct TreeIter { data: ffi::GtkTreeIter, pointer: *mut ff...
else { unsafe { std::mem::transmute(&self.data) } } } #[doc(hidden)] pub fn wrap_pointer(c_treeiter: *mut ffi::GtkTreeIter) -> TreeIter { unsafe { TreeIter { data: std::mem::uninitialized(), pointer: c_treeiter, is_own...
{ self.pointer }
conditional_block
tree_iter.rs
// Copyright 2013-2015, The Rust-GNOME Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT> use ffi; use std; pub struct TreeIter { data: ffi::GtkTreeIter, pointer: *mut ff...
} impl Drop for TreeIter { fn drop(&mut self) { if!self.pointer.is_null() && self.is_owned { unsafe { ffi::gtk_tree_iter_free(self.pointer) }; self.pointer = ::std::ptr::null_mut(); } } }
{ unsafe { TreeIter { data: std::mem::uninitialized(), pointer: c_treeiter, is_owned: false, is_true_pointer: true } } }
identifier_body
tree_iter.rs
// Copyright 2013-2015, The Rust-GNOME Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT> use ffi; use std; pub struct TreeIter { data: ffi::GtkTreeIter, pointer: *mut ff...
(&self) -> Option<TreeIter> { let tmp_pointer = unsafe { ffi::gtk_tree_iter_copy(self.pointer) }; if tmp_pointer.is_null() { None } else { unsafe { Some(TreeIter { data: std::mem::uninitialized(), pointer: tmp_point...
copy
identifier_name
tree_iter.rs
// Copyright 2013-2015, The Rust-GNOME Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT> use ffi; use std; pub struct TreeIter { data: ffi::GtkTreeIter, pointer: *mut ff...
if tmp_pointer.is_null() { None } else { unsafe { Some(TreeIter { data: std::mem::uninitialized(), pointer: tmp_pointer, is_owned: true, is_true_pointer: true }) ...
t } pub fn copy(&self) -> Option<TreeIter> { let tmp_pointer = unsafe { ffi::gtk_tree_iter_copy(self.pointer) };
random_line_split
objpools.rs
/* Copyright (c) 2016-2017, Robert Ou <rqou@robertou.com> All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of condit...
let addition_begin = self.storage.len(); let addition_end = addition_begin + inp.len(); self.storage.extend(inp.iter().cloned()); let new_idx = StringPoolIndexInternal { start: addition_begin, end: addition_end }; self.hashtable.insert(inp.to_...
{ return StringPoolIndexInternal { start: existing_idx.start, end: existing_idx.end, }; }
conditional_block
objpools.rs
/* Copyright (c) 2016-2017, Robert Ou <rqou@robertou.com> All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of condit...
() { let mut sp = StringPool::new(); let x = sp.add_latin1_str(b"test1"); let y = sp.add_latin1_str(b"test1"); assert_eq!(x, y); assert_eq!(sp.storage, b"test1"); } #[derive(Default)] struct ObjPoolTestObject { foo: u32 } #[test] fn objpool_basic...
stringpool_interns
identifier_name
objpools.rs
/* Copyright (c) 2016-2017, Robert Ou <rqou@robertou.com> All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of condit...
} } impl<T> Eq for ObjPoolIndex<T> { } pub struct ObjPool<T> { storage: Vec<T> } impl<T: Default> ObjPool<T> { pub fn new() -> ObjPool<T> { ObjPool {storage: Vec::new()} } pub fn alloc(&mut self) -> ObjPoolIndex<T> { let i = self.storage.len(); let o = T::default(); ...
} impl<T> PartialEq for ObjPoolIndex<T> { fn eq(&self, other: &ObjPoolIndex<T>) -> bool { self.i == other.i
random_line_split
decode.rs
//! Decodes a Bitterlemon-encoded byte stream into its original bit stream. use std::iter::Iterator; use std::result; /// Decodes a Bitterlemon byte stream into an iterator of `bool`s. /// `source` can be any iterator that yields `u8` values. /// /// # Errors /// /// Unlike encoding, decoding has a chance of failure....
else { byte } } #[derive(Debug)] enum DecodeState { Pending, // should pull Run(u8, bool), // run count, is_set Frame(u8, u8, u8), // frame bit count, stage contents, stage size Done, // iteration complete } #[cfg(test)] mod test_decoder { macro_rules! decoder { ( $($e:expr),* ) => { { let v = vec![$...
{ 0x80 }
conditional_block
decode.rs
//! Decodes a Bitterlemon-encoded byte stream into its original bit stream. use std::iter::Iterator; use std::result; /// Decodes a Bitterlemon byte stream into an iterator of `bool`s. /// `source` can be any iterator that yields `u8` values. /// /// # Errors /// /// Unlike encoding, decoding has a chance of failure....
fn byte_to_run_size(byte: u8) -> u8 { let byte = byte & 0x3f; if byte == 0 { 0x40 } else { byte } } fn byte_to_frame_size(byte: u8) -> u8 { if byte == 0 { 0x80 } else { byte } } #[derive(Debug)] enum DecodeState { Pending, // should pull Run(u8, bool), // run count, is_set Frame(u8, u8, u8), // frame bit count...
}
random_line_split
decode.rs
//! Decodes a Bitterlemon-encoded byte stream into its original bit stream. use std::iter::Iterator; use std::result; /// Decodes a Bitterlemon byte stream into an iterator of `bool`s. /// `source` can be any iterator that yields `u8` values. /// /// # Errors /// /// Unlike encoding, decoding has a chance of failure....
(&mut self) -> Option<<Self as Iterator>::Item> { let (to_return, next_state) = match self.state { DecodeState::Pending => unreachable!(), DecodeState::Done => { return None; }, DecodeState::Run(ref mut remaining, ref run_mode) => { *remaining -= 1; (*run_mode, if *remaining == 0 {Some(DecodeStat...
next_from_existing
identifier_name
decode.rs
//! Decodes a Bitterlemon-encoded byte stream into its original bit stream. use std::iter::Iterator; use std::result; /// Decodes a Bitterlemon byte stream into an iterator of `bool`s. /// `source` can be any iterator that yields `u8` values. /// /// # Errors /// /// Unlike encoding, decoding has a chance of failure....
/// Manages the state for decoding a Bitterlemon byte stream. /// /// To perform a decoding, see [`decode`](#fn.decode). pub struct Decoder<S> { state: DecodeState, source: S, } /// Describes errors that can occur when decoding a Bitterlemon byte stream. #[derive(Debug, PartialEq, Eq)] pub enum Error { /// Input ...
{ Decoder::<S> { source: input, state: DecodeState::Pending, } }
identifier_body
filter.rs
// Copyright 2015, 2016 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any la...
let deserialized: Vec<Topic> = serde_json::from_str(s).unwrap(); assert_eq!(deserialized, vec![ VariadicValue::Single(H256::from_str("000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b").unwrap().into()), VariadicValue::Null, VariadicValue::Multiple(vec![ H256::from_str...
#[test] fn topic_deserialization() { let s = r#"["0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b", null, ["0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b", "0x0000000000000000000000000aff3454fce5edbc8cca8697c15331677e6ebccc"]]"#;
random_line_split
filter.rs
// Copyright 2015, 2016 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any la...
() { let filter = Filter { from_block: Some(BlockNumber::Earliest), to_block: Some(BlockNumber::Latest), address: Some(VariadicValue::Multiple(vec![])), topics: Some(vec![ VariadicValue::Null, VariadicValue::Single("000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b".into()), Var...
filter_conversion
identifier_name
filter.rs
// Copyright 2015, 2016 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any la...
} #[cfg(test)] mod tests { use serde_json; use std::str::FromStr; use util::hash::H256; use super::{VariadicValue, Topic, Filter}; use v1::types::BlockNumber; use ethcore::filter::Filter as EthFilter; use ethcore::client::BlockId; #[test] fn topic_deserialization() { let s = r#"["0x00000000000000000000000...
{ match *self { FilterChanges::Logs(ref logs) => logs.serialize(s), FilterChanges::Hashes(ref hashes) => hashes.serialize(s), FilterChanges::Empty => (&[] as &[Value]).serialize(s), } }
identifier_body
mmap.rs
// Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 use std::io::Error as IOError; use std::os::unix::io::RawFd; use std::result::Result; use vm_memory::{MmapRegion, MmapRegionError}; #[derive(Debug)] pub enum Error { Os(IOError), BuildMmapRegion(...
// Safe because the mmap did not return error. unsafe { MmapRegion::build_raw(ptr as *mut u8, size, prot, flags).map_err(Error::BuildMmapRegion) } }
{ return Err(Error::Os(IOError::last_os_error())); }
conditional_block
mmap.rs
// Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 use std::io::Error as IOError; use std::os::unix::io::RawFd; use std::result::Result; use vm_memory::{MmapRegion, MmapRegionError}; #[derive(Debug)] pub enum Error { Os(IOError), BuildMmapRegion(...
MmapRegion::build_raw(ptr as *mut u8, size, prot, flags).map_err(Error::BuildMmapRegion) } }
return Err(Error::Os(IOError::last_os_error())); } // Safe because the mmap did not return error. unsafe {
random_line_split
mmap.rs
// Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 use std::io::Error as IOError; use std::os::unix::io::RawFd; use std::result::Result; use vm_memory::{MmapRegion, MmapRegionError}; #[derive(Debug)] pub enum Error { Os(IOError), BuildMmapRegion(...
(size: usize, fd: RawFd, offset: i64) -> Result<MmapRegion, Error> { let prot = libc::PROT_READ | libc::PROT_WRITE; let flags = libc::MAP_SHARED | libc::MAP_POPULATE; // Safe because values are valid and we check the return value. let ptr = unsafe { libc::mmap(std::ptr::null_mut(), size, prot, flags, f...
mmap
identifier_name
paintworkletglobalscope.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 canvas_traits::CanvasData; use dom::bindings::callback::CallbackContainer; use dom::bindings::cell::DOMRefCell...
(&self, name: DOMString, paint_ctor: Rc<VoidFunction>) -> Fallible<()> { let name = Atom::from(name); let cx = self.worklet_global.get_cx(); rooted!(in(cx) let paint_obj = paint_ctor.callback_holder().get()); rooted!(in(cx) let paint_val = ObjectValue(paint_obj.get())); debug!("...
RegisterPaint
identifier_name
paintworkletglobalscope.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 canvas_traits::CanvasData; use dom::bindings::callback::CallbackContainer; use dom::bindings::cell::DOMRefCell...
}; // Steps 5.2-5.4 // TODO: the spec requires calling the constructor now, but we might want to // prepopulate the paint instance in `RegisterPaint`, to avoid calling it in // the primary worklet thread. // https://github.com/servo/servo/issues/17377 rooted!(in...
{ // Step 5.1 if !definition.constructor_valid_flag.get() { debug!("Drawing invalid paint definition {}.", name); return self.invalid_image(size_in_dpx, vec![]); } class_constructor.set(definition.class_constructor.g...
conditional_block
paintworkletglobalscope.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 canvas_traits::CanvasData; use dom::bindings::callback::CallbackContainer; use dom::bindings::cell::DOMRefCell...
struct PaintDefinition { class_constructor: Heap<JSVal>, paint_function: Heap<JSVal>, constructor_valid_flag: Cell<bool>, context_alpha_flag: bool, // TODO: the spec calls for fresh rendering contexts each time a paint image is drawn, // but to avoid having the primary worklet thread create a ne...
#[derive(JSTraceable, HeapSizeOf)] #[must_root]
random_line_split
class-cast-to-trait.rs
// run-pass #![allow(dead_code)] #![allow(unused_mut)] #![allow(non_camel_case_types)] // ignore-freebsd FIXME fails on BSD trait noisy { fn speak(&mut self); } struct cat { meows: usize, how_hungry: isize, name: String, } impl noisy for cat { fn speak(&mut self) { self.meow(); } } impl cat { pub fn e...
else { println!("Not hungry!"); return false; } } } impl cat { fn meow(&mut self) { println!("Meow"); self.meows += 1; if self.meows % 5 == 0 { self.how_hungry += 1; } } } fn cat(in_x : usize, in_y : isize, in_name: String) -> cat { cat { ...
{ println!("OM NOM NOM"); self.how_hungry -= 2; return true; }
conditional_block
class-cast-to-trait.rs
// run-pass #![allow(dead_code)] #![allow(unused_mut)] #![allow(non_camel_case_types)] // ignore-freebsd FIXME fails on BSD trait noisy { fn speak(&mut self); } struct cat { meows: usize, how_hungry: isize, name: String, } impl noisy for cat { fn speak(&mut self) { self.meow(); } } impl cat { pub fn e...
(&mut self) { println!("Meow"); self.meows += 1; if self.meows % 5 == 0 { self.how_hungry += 1; } } } fn cat(in_x : usize, in_y : isize, in_name: String) -> cat { cat { meows: in_x, how_hungry: in_y, name: in_name } } pub fn main() { let mut n...
meow
identifier_name
class-cast-to-trait.rs
// run-pass #![allow(dead_code)] #![allow(unused_mut)] #![allow(non_camel_case_types)] // ignore-freebsd FIXME fails on BSD trait noisy { fn speak(&mut self); } struct cat { meows: usize, how_hungry: isize, name: String, } impl noisy for cat { fn speak(&mut self) { self.meow(); } } impl cat { pub fn e...
pub fn main() { let mut nyan = cat(0, 2, "nyan".to_string()); let mut nyan: &mut dyn noisy = &mut nyan; nyan.speak(); }
{ cat { meows: in_x, how_hungry: in_y, name: in_name } }
identifier_body
class-cast-to-trait.rs
// run-pass #![allow(dead_code)] #![allow(unused_mut)] #![allow(non_camel_case_types)] // ignore-freebsd FIXME fails on BSD trait noisy { fn speak(&mut self); } struct cat { meows: usize, how_hungry: isize, name: String, } impl noisy for cat { fn speak(&mut self) { self.meow(); } } impl cat { pub fn e...
if self.meows % 5 == 0 { self.how_hungry += 1; } } } fn cat(in_x : usize, in_y : isize, in_name: String) -> cat { cat { meows: in_x, how_hungry: in_y, name: in_name } } pub fn main() { let mut nyan = cat(0, 2, "nyan".to_string()); let mut nyan: &mut d...
self.meows += 1;
random_line_split
media_queries.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/. */ //! [Media queries][mq]. //! //! [mq]: https://drafts.csswg.org/mediaqueries/ use Atom; use app_units::Au; use cs...
impl MediaList { pub fn evaluate(&self, device: &Device) -> bool { let viewport_size = device.au_viewport_size(); // Check if it is an empty media query list or any queries match (OR condition) // https://drafts.csswg.org/mediaqueries-4/#mq-list self.media_queries.is_empty() || se...
{ if input.is_exhausted() { return Default::default() } let mut media_queries = vec![]; loop { media_queries.push( input.parse_until_before(Delimiter::Comma, MediaQuery::parse).ok() .unwrap_or_else(MediaQuery::never_matching)); match input.next() { ...
identifier_body
media_queries.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/. */ //! [Media queries][mq]. //! //! [mq]: https://drafts.csswg.org/mediaqueries/ use Atom; use app_units::Au; use cs...
<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { if let Some(qual) = self.qualifier { try!(qual.to_css(dest)); try!(write!(dest, " ")); } match self.media_type { MediaQueryType::All => { // We need to print "all" if th...
to_css
identifier_name
media_queries.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/. */ //! [Media queries][mq]. //! //! [mq]: https://drafts.csswg.org/mediaqueries/ use Atom; use app_units::Au; use cs...
if input.is_exhausted() { return Default::default() } let mut media_queries = vec![]; loop { media_queries.push( input.parse_until_before(Delimiter::Comma, MediaQuery::parse).ok() .unwrap_or_else(MediaQuery::never_matching)); match input.next() { ...
} } pub fn parse_media_query_list(input: &mut Parser) -> MediaList {
random_line_split
mod.rs
// // Copyright (c) 2016, Boris Popov <popov@whitekefir.ru> // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. // extern crate libc; use self::libc::c_void; use sel...
_ => { let mut mess = "Unexpected error in mount::".to_string(); mess += s; mess += "!"; Err(mess) } } } ////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////// #[test] #[i...
0 => Ok(()), -1 => Err(getStrError()),
random_line_split
mod.rs
// // Copyright (c) 2016, Boris Popov <popov@whitekefir.ru> // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. // extern crate libc; use self::libc::c_void; use sel...
(result: c_int, s: &str) -> Result<(), String> { match result { 0 => Ok(()), -1 => Err(getStrError()), _ => { let mut mess = "Unexpected error in mount::".to_string(); mess += s; mess += "!"; Err(mess) } } } //////////////////////...
get_result
identifier_name
mod.rs
// // Copyright (c) 2016, Boris Popov <popov@whitekefir.ru> // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. // extern crate libc; use self::libc::c_void; use sel...
fn get_result(result: c_int, s: &str) -> Result<(), String> { match result { 0 => Ok(()), -1 => Err(getStrError()), _ => { let mut mess = "Unexpected error in mount::".to_string(); mess += s; mess += "!"; Err(mess) } } } ///////...
{ let c_target = CString::new(target).unwrap(); let target_raw = c_target.into_raw(); let mut result: c_int = 0; unsafe { result = libc::umount(target_raw); } return get_result(result, "umount"); }
identifier_body
mod.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ #![allow(unsafe_code)] // This is needed for the constants in atom_macro.rs, because we have some // atoms whose...
(nsAtom); /// The number of static atoms we have. const STATIC_ATOM_COUNT: usize = GkAtoms_Atoms_AtomsCount as usize; /// Returns the Gecko static atom array. /// /// We have this rather than use rust-bindgen to generate /// mozilla::detail::gGkAtoms and then just reference gGkAtoms.mAtoms, so we /// avoid a problem ...
WeakAtom
identifier_name
mod.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ #![allow(unsafe_code)] // This is needed for the constants in atom_macro.rs, because we have some // atoms whose...
a.iter().zip(b).all(|(&a16, &b16)| { if a16 <= 0x7F && b16 <= 0x7F { (a16 as u8).eq_ignore_ascii_case(&(b16 as u8)) } else { a16 == b16 } }) } } impl fmt::Debug for WeakAtom { fn fmt(&self, w: &mut fmt::Formatter) -> fmt::Res...
{ return false; }
conditional_block
mod.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ #![allow(unsafe_code)] // This is needed for the constants in atom_macro.rs, because we have some // atoms whose...
#[inline] fn from(string: &str) -> Atom { debug_assert!(string.len() <= u32::max_value() as usize); unsafe { Atom::from_addrefed(Gecko_Atomize( string.as_ptr() as *const _, string.len() as u32, )) } } } impl<'a> From<&'a [u16]>...
impl<'a> From<&'a str> for Atom {
random_line_split
mod.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ #![allow(unsafe_code)] // This is needed for the constants in atom_macro.rs, because we have some // atoms whose...
// NOTE: don't expose this, since it's slow, and easy to be misused. fn chars(&self) -> DecodeUtf16<Cloned<slice::Iter<u16>>> { char::decode_utf16(self.as_slice().iter().cloned()) } /// Execute `cb` with the string that this atom represents. /// /// Find alternatives to this function ...
{ let string = if self.is_static() { let atom_ptr = self.as_ptr() as *const nsStaticAtom; let string_offset = unsafe { (*atom_ptr).mStringOffset }; let string_offset = -(string_offset as isize); let u8_ptr = atom_ptr as *const u8; // It is safe to use ...
identifier_body
iobuf.rs
// Copyright 2021 The Chromium OS Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use std::ops::{Deref, DerefMut}; use data_model::IoBufMut; /// A trait for describing regions of memory to be used for IO. /// /// # Safety /// /// T...
(&mut self) -> &[IoBufMut] { &self.iobuf } } #[cfg(test)] mod test { use super::*; #[test] fn len() { let buf = OwnedIoBuf::new(vec![0xcc; 64]); assert_eq!(buf.len(), 64); } #[test] fn advance() { let mut buf = OwnedIoBuf::new(vec![0xcc; 64]); buf...
as_iobufs
identifier_name
iobuf.rs
// Copyright 2021 The Chromium OS Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use std::ops::{Deref, DerefMut}; use data_model::IoBufMut; /// A trait for describing regions of memory to be used for IO. /// /// # Safety /// /// T...
/// # } /// # cros_async::Executor::new().run_until(do_it()).unwrap().unwrap(); /// ``` pub struct OwnedIoBuf { buf: Box<[u8]>, // This IoBufMut has a static lifetime because it points to the data owned by `buf` so the // pointer is always valid for the lifetime of this struct. iobuf: [IoBufMut<'static>...
random_line_split
issue-17121.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
pub fn new_from_str<'a>(s: &'a str) -> Lexer<&'a [u8]> { Lexer::new_from_reader(s.as_bytes()) } } fn main() {}
{ Ok(Lexer::new_from_reader(File::open(p)?)) }
identifier_body
issue-17121.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ Ok(Lexer::new_from_reader(File::open(p)?)) } pub fn new_from_str<'a>(s: &'a str) -> Lexer<&'a [u8]> { Lexer::new_from_reader(s.as_bytes()) } } fn main() {}
Lexer{reader: BufReader::new(r)} } pub fn new_from_file(p: &str) -> io::Result<Lexer<File>>
random_line_split
issue-17121.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 ...
(r: R) -> Lexer<R> { Lexer{reader: BufReader::new(r)} } pub fn new_from_file(p: &str) -> io::Result<Lexer<File>> { Ok(Lexer::new_from_reader(File::open(p)?)) } pub fn new_from_str<'a>(s: &'a str) -> Lexer<&'a [u8]> { Lexer::new_from_reader(s.as_bytes()) } } fn ...
new_from_reader
identifier_name
ufcs-explicit-self-bad.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 ...
f: 1, }; println!("{} {}", bar.foo(2), bar.bar(2)); }
let bar = box Bar {
random_line_split
ufcs-explicit-self-bad.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 ...
} struct Bar<T> { f: T, } impl<T> Bar<T> { fn foo(self: Bar<int>, x: int) -> int { //~ ERROR mismatched self type //~^ ERROR not a valid type for `self` x } fn bar(self: &Bar<uint>, x: int) -> int { //~ ERROR mismatched self type //~^ ERROR not a valid type for `self` x } } fn ...
{ //~ ERROR mismatched self type //~^ ERROR not a valid type for `self` self.f + x }
identifier_body
ufcs-explicit-self-bad.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 ...
(self: Bar<int>, x: int) -> int { //~ ERROR mismatched self type //~^ ERROR not a valid type for `self` x } fn bar(self: &Bar<uint>, x: int) -> int { //~ ERROR mismatched self type //~^ ERROR not a valid type for `self` x } } fn main() { let foo = box Foo { f: 1, }; pr...
foo
identifier_name
calc2.rs
// Copyright 2014 Pierre Talbot (IRCAM) // 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...
}
}
random_line_split
calc2.rs
// Copyright 2014 Pierre Talbot (IRCAM) // 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...
{ Add, Sub, Mul, Div, Exp } oak! { // Optional stream declaration. type Stream<'a> = StrStream<'a>; program = spacing expression expression = term (term_op term)* > fold_left term = exponent (factor_op exponent)* > fold_left exponent = (factor exponent_op)* factor > fold_right factor:...
BinOp
identifier_name
eventlistener.rs
#![allow(non_snake_case)] #![allow(unused_variables)] use super::super::win::types::{WndProc,MSG,WPARAM,LPARAM}; use super::super::win::wnd::DWnd; use super::super::win::api::{CallWindowProcW}; use std::rc::Rc; use std::cell::{RefCell}; use std::collections::HashMap; /* 每一个窗口都有一个自有的事件处理器.它们通过哈希表关联在一起. */...
indowEx(.....); unHookEventCreate(); hWin } } trait Window for HWND{ fn Window(title:&str, x:int,y:int, w:int,h:int)->HWND { let hWin; let mut event = WindowEventProcesser::new(); hookEventCreate(event) HWND = CreateWindowEx(.....); unHookEventCreate(); hWin } } let w...
hWin; let mut event = WindowWdgetsProcesser::new(); hookEventCreate(event) HWND = CreateW
identifier_body
eventlistener.rs
#![allow(non_snake_case)] #![allow(unused_variables)] use super::super::win::types::{WndProc,MSG,WPARAM,LPARAM}; use super::super::win::wnd::DWnd; use super::super::win::api::{CallWindowProcW}; use std::rc::Rc; use std::cell::{RefCell}; use std::collections::HashMap; /* 每一个窗口都有一个自有的事件处理器.它们通过哈希表关联在一起. */...
// button clicked. }); */
window.on(EventType::Size,|e|{ // you code is here.... }); window.onCommand(button.getId(), |e|{
random_line_split
eventlistener.rs
#![allow(non_snake_case)] #![allow(unused_variables)] use super::super::win::types::{WndProc,MSG,WPARAM,LPARAM}; use super::super::win::wnd::DWnd; use super::super::win::api::{CallWindowProcW}; use std::rc::Rc; use std::cell::{RefCell}; use std::collections::HashMap; /* 每一个窗口都有一个自有的事件处理器.它们通过哈希表关联在一起. */...
trait Button for HWND{ fn Button(...)->HWND { let hWin; let mut event = WindowWdgetsProcesser::new(); hookEventCreate(event) HWND = CreateWindowEx(.....); unHookEventCreate(); hWin } } trait Window for HWND{ fn Window(title:&str, x:int,y:int, w:int,h:int)->HWND { let hWin;...
} /*
identifier_name
builtin-superkinds-capabilities-transitive.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 Send. Basically this just makes sure rustc is using // each_bound_trait_and_supertraits in type_contents correctly. trait Bar : Send { } trait Foo : Bar { } impl <T: Send> Foo for T { } impl <T: Send> Bar for T { } fn foo<T: Foo>(val: T, chan: Sender<T>) { chan.send(val); } pub fn main() { let (tx, rx)...
// Tests "transitivity" of super-builtin-kinds on traits. Here, if // we have a Foo, we know we have a Bar, and if we have a Bar, we // know we have a Send. So if we have a Foo we should know we have
random_line_split
builtin-superkinds-capabilities-transitive.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ let (tx, rx) = channel(); foo(31337, tx); assert!(rx.recv() == 31337); }
identifier_body
builtin-superkinds-capabilities-transitive.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: Foo>(val: T, chan: Sender<T>) { chan.send(val); } pub fn main() { let (tx, rx) = channel(); foo(31337, tx); assert!(rx.recv() == 31337); }
foo
identifier_name
parser.rs
use {Symbol, Rules, Text2Parse, Error, error}; use parser; use atom::parse_symbol; use ast; pub struct Config<'a> { pub text2parse: &'a Text2Parse, pub rules: &'a Rules, } pub trait Parse { fn parse(&self, conf: &Config, status: parser::Status) -> Result<(parser:...
pub fn inc_chars(&mut self, s: &str) -> &Self { for ch in s.chars() { self.inc_ch(ch); } self } } pub mod tools { pub use atom::Atom; pub use expression::{Expression, MultiExpr, NRep}; pub fn lit(s: &str) -> Expression { Expression::Simple(Atom::Lite...
{ let n = self.n; self.inc_ch(text2parse.0.chars().nth(n).unwrap_or('?')) }
identifier_body
parser.rs
use {Symbol, Rules, Text2Parse, Error, error}; use parser; use atom::parse_symbol; use ast; pub struct Config<'a> { pub text2parse: &'a Text2Parse, pub rules: &'a Rules, } pub trait Parse { fn parse(&self, conf: &Config, status: parser::Status) -> Result<(parser:...
(&mut self, ch: char) -> &Self { match ch { '\n' => { self.n += 1; self.col = 0; self.row += 1; } _ => { self.n += 1; self.col += 1; } }; self } pub fn inc_char...
inc_ch
identifier_name
parser.rs
use {Symbol, Rules, Text2Parse, Error, error}; use parser; use atom::parse_symbol; use ast; pub struct Config<'a> { pub text2parse: &'a Text2Parse, pub rules: &'a Rules, } pub trait Parse { fn parse(&self, conf: &Config, status: parser::Status) -> Result<(parser:...
} pub fn update_deep_error(mut self, error: &Error) -> Self { self.deep_error = match self.deep_error { Some(ref derr) => { if error.pos.n > derr.pos.n { Some(error.clone()) } else { self.deep_error.clone() ...
} } pub fn inc_depth(&self) -> Self { Status { depth: Depth(self.depth.0 + 1), ..self.clone() }
random_line_split
parser.rs
use {Symbol, Rules, Text2Parse, Error, error}; use parser; use atom::parse_symbol; use ast; pub struct Config<'a> { pub text2parse: &'a Text2Parse, pub rules: &'a Rules, } pub trait Parse { fn parse(&self, conf: &Config, status: parser::Status) -> Result<(parser:...
} None => Some(error.clone()), }; self } } impl Possition { pub fn new() -> Self { Possition { n: 0, col: 1, row: 1, } } fn inc_ch(&mut self, ch: char) -> &Self { match ch { '\n' => { ...
{ self.deep_error.clone() }
conditional_block
penneys_game.rs
// http://rosettacode.org/wiki/Penney's_game // H = true, T = false extern crate rand; use std::io::{stdout, stdin, Read, Write}; use std::thread; use std::time::Duration; use rand::{Rng, thread_rng}; fn toss_coin(print:bool) -> char { let c : char; if thread_rng().gen::<bool>() {c = 'H'} else {c = 'T'} ...
continue; } return seq; } } fn main() { println!("--Penney's game--"); loop { let useq : String; let aiseq : String; if thread_rng().gen::<bool>() { println!("You choose first!"); useq = read_sequence(None); println!("Y...
) { println!("Please enter correct sequence!");
random_line_split
penneys_game.rs
// http://rosettacode.org/wiki/Penney's_game // H = true, T = false extern crate rand; use std::io::{stdout, stdin, Read, Write}; use std::thread; use std::time::Duration; use rand::{Rng, thread_rng}; fn toss_coin(print:bool) -> char { let c : char; if thread_rng().gen::<bool>() {c = 'H'} else {c = 'T'} ...
(used_seq : Option<&str>) -> String { let mut seq = String::new(); loop { seq.clear(); println!("Please, enter sequence of 3 coins: H (heads) or T (tails): "); stdin().read_line(&mut seq).ok().expect("failed to read line"); seq = seq.trim().to_uppercase(); if!( ...
read_sequence
identifier_name
penneys_game.rs
// http://rosettacode.org/wiki/Penney's_game // H = true, T = false extern crate rand; use std::io::{stdout, stdin, Read, Write}; use std::thread; use std::time::Duration; use rand::{Rng, thread_rng}; fn toss_coin(print:bool) -> char { let c : char; if thread_rng().gen::<bool>() {c = 'H'} else {c = 'T'} ...
for _ in 0..2 { //toss first 2 coins coins.push(toss_coin(true)); thread::sleep(Duration::from_millis(500)); } loop { coins.push(toss_coin(true)); thread::sleep(Duration::from_millis(500)); if coins.contains(&useq) { pri...
{ println!("--Penney's game--"); loop { let useq : String; let aiseq : String; if thread_rng().gen::<bool>() { println!("You choose first!"); useq = read_sequence(None); println!("Your sequence: {}", useq); aiseq = gen_sequence( Some(&useq)...
identifier_body