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
lithos_switch.rs
extern crate libc; extern crate nix; extern crate env_logger; extern crate regex; extern crate argparse; extern crate quire; #[macro_use] extern crate log; extern crate lithos; use std::env; use std::io::{stderr, Read, Write}; use std::process::exit; use std::path::{Path, PathBuf}; use std::str::FromStr; use std::fs:...
}; let sandbox_fn = master_cfg.parent().unwrap() .join(&master.sandboxes_dir) .join(&(sandbox_name.clone() + ".yaml")); let sandbox: SandboxConfig = match parse_config(&sandbox_fn, &SandboxConfig::validator(), &Options::default()) { Ok(cfg) => cfg, Err(e) => { ...
{ return Err(format!("Can't parse master config: {}", e)); }
conditional_block
lithos_switch.rs
extern crate libc; extern crate nix; extern crate env_logger; extern crate regex; extern crate argparse; extern crate quire; #[macro_use] extern crate log; extern crate lithos; use std::env; use std::io::{stderr, Read, Write}; use std::process::exit; use std::path::{Path, PathBuf}; use std::str::FromStr; use std::fs:...
pid_file.display()); } }; return Ok(()); } fn main() { if env::var("RUST_LOG").is_err() { env::set_var("RUST_LOG", "warn"); } env_logger::init(); let mut master_config = PathBuf::from("/etc/lithos/master.yaml"); let mut verbose = false; let mut config_...
} None => { warn!("Can't read pid file {}. Probably daemon is not running.",
random_line_split
lithos_switch.rs
extern crate libc; extern crate nix; extern crate env_logger; extern crate regex; extern crate argparse; extern crate quire; #[macro_use] extern crate log; extern crate lithos; use std::env; use std::io::{stderr, Read, Write}; use std::process::exit; use std::path::{Path, PathBuf}; use std::str::FromStr; use std::fs:...
"Verbose configuration"); ap.refer(&mut sandbox_name) .add_argument("sandbox", Parse, "Name of the sandbox which configuration will be switched for") .required() .metavar("NAME"); ap.refer(&mut config_file) .add_argument("new_config", Parse, " ...
{ if env::var("RUST_LOG").is_err() { env::set_var("RUST_LOG", "warn"); } env_logger::init(); let mut master_config = PathBuf::from("/etc/lithos/master.yaml"); let mut verbose = false; let mut config_file = PathBuf::from(""); let mut sandbox_name = "".to_string(); { let m...
identifier_body
lithos_switch.rs
extern crate libc; extern crate nix; extern crate env_logger; extern crate regex; extern crate argparse; extern crate quire; #[macro_use] extern crate log; extern crate lithos; use std::env; use std::io::{stderr, Read, Write}; use std::process::exit; use std::path::{Path, PathBuf}; use std::str::FromStr; use std::fs:...
() { if env::var("RUST_LOG").is_err() { env::set_var("RUST_LOG", "warn"); } env_logger::init(); let mut master_config = PathBuf::from("/etc/lithos/master.yaml"); let mut verbose = false; let mut config_file = PathBuf::from(""); let mut sandbox_name = "".to_string(); { le...
main
identifier_name
fs.rs
// Copyright 2016 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 res = cvt(syscall::frename(fd, new.to_str().unwrap())); cvt(syscall::close(fd))?; res?; Ok(()) } pub fn set_perm(p: &Path, perm: FilePermissions) -> io::Result<()> { cvt(syscall::chmod(p.to_str().unwrap(), perm.mode as usize))?; Ok(()) } pub fn rmdir(p: &Path) -> io::Result<()> { cvt(s...
syscall::O_CLOEXEC | syscall::O_STAT | syscall::O_NOFOLLOW))?;
random_line_split
fs.rs
// Copyright 2016 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 truncate(&mut self, truncate: bool) { self.truncate = truncate; } pub fn create(&mut self, create: bool) { self.create = create; } pub fn create_new(&mut self, create_new: bool) { self.create_new = create_new; } pub fn custom_flags(&mut self, flags: i32) { self.custom_flags = flags; } pub f...
{ self.append = append; }
identifier_body
fs.rs
// Copyright 2016 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) -> io::Result<File> { self.0.duplicate().map(File) } pub fn dup(&self, buf: &[u8]) -> io::Result<File> { let fd = cvt(syscall::dup(*self.fd().as_inner() as usize, buf))?; Ok(File(FileDesc::new(fd))) } pub fn set_permissions(&self, perm: FilePermissions) -> io::Result<()...
duplicate
identifier_name
mkfifo.rs
#![crate_name = "uu_mkfifo"] /* * This file is part of the uutils coreutils package. * * (c) Michael Gehring <mg@ebfe.org> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ extern crate getopts; extern crate libc; #[macro_use] ext...
(args: Vec<String>) -> i32 { let mut opts = getopts::Options::new(); opts.optopt("m", "mode", "file permissions for the fifo", "(default 0666)"); opts.optflag("h", "help", "display this help and exit"); opts.optflag("V", "version", "output version information and exit"); let matches = match opts.p...
uumain
identifier_name
mkfifo.rs
#![crate_name = "uu_mkfifo"] /* * This file is part of the uutils coreutils package. * * (c) Michael Gehring <mg@ebfe.org> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ extern crate getopts; extern crate libc; #[macro_use] ext...
Usage: {0} [OPTIONS] NAME... Create a FIFO with the given name.", NAME, VERSION); print!("{}", opts.usage(&msg)); if matches.free.is_empty() { return 1; } return 0; } let mode = match matches.opt_str("m") { Some(m) => match usize::from_str_radix(&m, 8) { ...
{ let mut opts = getopts::Options::new(); opts.optopt("m", "mode", "file permissions for the fifo", "(default 0666)"); opts.optflag("h", "help", "display this help and exit"); opts.optflag("V", "version", "output version information and exit"); let matches = match opts.parse(&args[1..]) { ...
identifier_body
mkfifo.rs
#![crate_name = "uu_mkfifo"] /* * This file is part of the uutils coreutils package. * * (c) Michael Gehring <mg@ebfe.org> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ extern crate getopts; extern crate libc; #[macro_use] ext...
let mode = match matches.opt_str("m") { Some(m) => match usize::from_str_radix(&m, 8) { Ok(m) => m, Err(e)=> { show_error!("invalid mode: {}", e); return 1; } }, None => 0o666, }; let mut exit_status = 0; for ...
{ let msg = format!("{0} {1} Usage: {0} [OPTIONS] NAME... Create a FIFO with the given name.", NAME, VERSION); print!("{}", opts.usage(&msg)); if matches.free.is_empty() { return 1; } return 0; }
conditional_block
binnode.rs
use std::collections::Bitv; use BinGraph; /// Contains a binary state and the choices. #[deriving(PartialEq, Eq, Show, Clone)] pub struct BinNode { /// The state composed of bits. pub state: Bitv, /// The choices represented as bits that can be flipped. pub choices: Bitv } impl BinNode { /// Gets ...
) } }
{ f(i) }
conditional_block
binnode.rs
use std::collections::Bitv; use BinGraph; /// Contains a binary state and the choices. #[deriving(PartialEq, Eq, Show, Clone)] pub struct BinNode { /// The state composed of bits. pub state: Bitv, /// The choices represented as bits that can be flipped. pub choices: Bitv } impl BinNode { /// Gets ...
/// Call closure for each available choice. #[inline(always)] pub fn with_choices(&self, f: |i: uint|) { for i in range(0, self.choices.len()) .zip(self.choices.iter()) .filter(|&(_, v)| v) .map(|(i, _)| i ) { f(i) } } /// Calls ...
random_line_split
binnode.rs
use std::collections::Bitv; use BinGraph; /// Contains a binary state and the choices. #[deriving(PartialEq, Eq, Show, Clone)] pub struct BinNode { /// The state composed of bits. pub state: Bitv, /// The choices represented as bits that can be flipped. pub choices: Bitv } impl BinNode { /// Gets ...
/// Call closure for each available choice. #[inline(always)] pub fn with_choices(&self, f: |i: uint|) { for i in range(0, self.choices.len()) .zip(self.choices.iter()) .filter(|&(_, v)| v) .map(|(i, _)| i ) { f(i) } } /// Calls...
{ BinNode { state: pairs.iter().map(|&(a, _)| a).collect(), choices: pairs.iter().map(|&(_, b)| b).collect() } }
identifier_body
binnode.rs
use std::collections::Bitv; use BinGraph; /// Contains a binary state and the choices. #[deriving(PartialEq, Eq, Show, Clone)] pub struct BinNode { /// The state composed of bits. pub state: Bitv, /// The choices represented as bits that can be flipped. pub choices: Bitv } impl BinNode { /// Gets ...
(&self, f: |i: uint|) { for i in range(0, self.choices.len()) .zip(self.choices.iter()) .filter(|&(_, v)| v) .map(|(i, _)| i ) { f(i) } } /// Calls closure for all choices that are not in graph. #[inline(always)] pub fn with_choices_n...
with_choices
identifier_name
node_void_ptr.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/. */ //! CSS library requires that DOM nodes be convertable to *c_void through this trait extern mod netsurfcss; use d...
(node: *libc::c_void) -> AbstractNode { assert!(node.is_not_null()); unsafe { cast::transmute(node) } } fn to_void_ptr(&self) -> *libc::c_void { unsafe { cast::transmute(*self) } } }
from_void_ptr
identifier_name
node_void_ptr.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/. */ //! CSS library requires that DOM nodes be convertable to *c_void through this trait extern mod netsurfcss; use d...
}
{ unsafe { cast::transmute(*self) } }
identifier_body
node_void_ptr.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/. */ //! CSS library requires that DOM nodes be convertable to *c_void through this trait extern mod netsurfcss; use d...
fn from_void_ptr(node: *libc::c_void) -> AbstractNode { assert!(node.is_not_null()); unsafe { cast::transmute(node) } } fn to_void_ptr(&self) -> *libc::c_void { unsafe { cast::transmute(*self) } } }
impl VoidPtrLike for AbstractNode {
random_line_split
lmmsg.rs
// Copyright © 2015-2017 winapi-rs developers // Licensed under the Apache License, Version 2.0 // <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. // All files in the project carrying such notice may not be copied,...
pub type LPMSG_INFO_1 = *mut MSG_INFO_1; pub const MSGNAME_NOT_FORWARDED: DWORD = 0; pub const MSGNAME_FORWARDED_TO: DWORD = 0x04; pub const MSGNAME_FORWARDED_FROM: DWORD = 0x10;
}} pub type PMSG_INFO_1 = *mut MSG_INFO_1;
random_line_split
reseeding.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 ...
/// Reseed the internal RNG if the number of bytes that have been /// generated exceed the threshold. pub fn reseed_if_necessary(&mut self) { if self.bytes_generated >= self.generation_threshold { self.reseeder.reseed(&mut self.rng); self.bytes_generated = 0; } ...
{ ReseedingRng { rng: rng, generation_threshold: generation_threshold, bytes_generated: 0, reseeder: reseeder } }
identifier_body
reseeding.rs
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. //! A wrapper aroun...
// 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. //
random_line_split
reseeding.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} } impl<R: Rng, Rsdr: Reseeder<R>> Rng for ReseedingRng<R, Rsdr> { fn next_u32(&mut self) -> u32 { self.reseed_if_necessary(); self.bytes_generated += 4; self.rng.next_u32() } fn next_u64(&mut self) -> u64 { self.reseed_if_necessary(); self.bytes_generated +=...
{ self.reseeder.reseed(&mut self.rng); self.bytes_generated = 0; }
conditional_block
reseeding.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 ...
<R, Rsdr> { rng: R, generation_threshold: usize, bytes_generated: usize, /// Controls the behaviour when reseeding the RNG. pub reseeder: Rsdr, } impl<R: Rng, Rsdr: Reseeder<R>> ReseedingRng<R, Rsdr> { /// Create a new `ReseedingRng` with the given parameters. /// /// # Arguments //...
ReseedingRng
identifier_name
error.rs
use std::error::Error as StdError; use std::string; use std::{fmt, io}; /// The errors that can arise while parsing a JSON stream. #[derive(Clone, Copy, PartialEq)] pub enum ErrorCode { InvalidSyntax, InvalidNumber, EOFWhileParsingObject, EOFWhileParsingArray, EOFWhileParsingValue, EOFWhilePars...
(&self) -> &str { "encoder error" } } impl fmt::Display for EncoderError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Debug::fmt(&self, f) } } impl From<fmt::Error> for EncoderError { fn from(err: fmt::Error) -> EncoderError { EncoderError::FmtError(err) } }
description
identifier_name
error.rs
use std::error::Error as StdError; use std::string; use std::{fmt, io}; /// The errors that can arise while parsing a JSON stream. #[derive(Clone, Copy, PartialEq)] pub enum ErrorCode { InvalidSyntax, InvalidNumber, EOFWhileParsingObject, EOFWhileParsingArray, EOFWhileParsingValue, EOFWhilePars...
NotUtf8, } #[derive(Debug)] pub enum ParserError { /// msg, line, col SyntaxError(ErrorCode, usize, usize), IoError(io::Error), } impl PartialEq for ParserError { fn eq(&self, other: &ParserError) -> bool { match (self, other) { (&ParserError::SyntaxError(msg0, line0, col0), &P...
UnexpectedEndOfHexEscape, UnrecognizedHex, NotFourDigit, ControlCharacterInString,
random_line_split
error.rs
use std::error::Error as StdError; use std::string; use std::{fmt, io}; /// The errors that can arise while parsing a JSON stream. #[derive(Clone, Copy, PartialEq)] pub enum ErrorCode { InvalidSyntax, InvalidNumber, EOFWhileParsingObject, EOFWhileParsingArray, EOFWhileParsingValue, EOFWhilePars...
} } #[derive(PartialEq, Debug)] pub enum DecoderError { ParseError(ParserError), ExpectedError(string::String, string::String), MissingFieldError(string::String), UnknownVariantError(string::String), ApplicationError(string::String), EOF, } #[derive(Copy, Debug)] pub enum EncoderError { ...
{ match error { ErrorCode::InvalidSyntax => "invalid syntax", ErrorCode::InvalidNumber => "invalid number", ErrorCode::EOFWhileParsingObject => "EOF While parsing object", ErrorCode::EOFWhileParsingArray => "EOF While parsing array", ErrorCode::EOFWhileParsingValue => "EOF Wh...
identifier_body
traits.rs
// Copyright (C) 2017-2020 Free Software Foundation, Inc. // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // Thi...
{ let d = 23.5f64; let u = 23u8; let td = &d as &T; let tu = &u as &T; println!(""); // set breakpoint here }
identifier_body
traits.rs
// Copyright (C) 2017-2020 Free Software Foundation, Inc. // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // Thi...
}
println!(""); // set breakpoint here
random_line_split
traits.rs
// Copyright (C) 2017-2020 Free Software Foundation, Inc. // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // Thi...
() { let d = 23.5f64; let u = 23u8; let td = &d as &T; let tu = &u as &T; println!(""); // set breakpoint here }
main
identifier_name
transmute_int_to_float.rs
use super::TRANSMUTE_INT_TO_FLOAT; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::sugg; use rustc_errors::Applicability; use rustc_hir::Expr; use rustc_lint::LateContext; use rustc_middle::ty::{self, Ty}; /// Checks for `transmute_int_to_float` lint. /// Returns `true` if it's triggered, otherwis...
match (&from_ty.kind(), &to_ty.kind()) { (ty::Int(_) | ty::Uint(_), ty::Float(_)) if!const_context => { span_lint_and_then( cx, TRANSMUTE_INT_TO_FLOAT, e.span, &format!("transmute from a `{}` to a `{}`", from_ty, to_ty), ...
from_ty: Ty<'tcx>, to_ty: Ty<'tcx>, args: &'tcx [Expr<'_>], const_context: bool, ) -> bool {
random_line_split
transmute_int_to_float.rs
use super::TRANSMUTE_INT_TO_FLOAT; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::sugg; use rustc_errors::Applicability; use rustc_hir::Expr; use rustc_lint::LateContext; use rustc_middle::ty::{self, Ty}; /// Checks for `transmute_int_to_float` lint. /// Returns `true` if it's triggered, otherwis...
"consider using", format!("{}::from_bits({})", to_ty, arg.to_string()), Applicability::Unspecified, ); }, ); true }, _ => false, } }
{ match (&from_ty.kind(), &to_ty.kind()) { (ty::Int(_) | ty::Uint(_), ty::Float(_)) if !const_context => { span_lint_and_then( cx, TRANSMUTE_INT_TO_FLOAT, e.span, &format!("transmute from a `{}` to a `{}`", from_ty, to_ty), ...
identifier_body
transmute_int_to_float.rs
use super::TRANSMUTE_INT_TO_FLOAT; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::sugg; use rustc_errors::Applicability; use rustc_hir::Expr; use rustc_lint::LateContext; use rustc_middle::ty::{self, Ty}; /// Checks for `transmute_int_to_float` lint. /// Returns `true` if it's triggered, otherwis...
<'tcx>( cx: &LateContext<'tcx>, e: &'tcx Expr<'_>, from_ty: Ty<'tcx>, to_ty: Ty<'tcx>, args: &'tcx [Expr<'_>], const_context: bool, ) -> bool { match (&from_ty.kind(), &to_ty.kind()) { (ty::Int(_) | ty::Uint(_), ty::Float(_)) if!const_context => { span_lint_and_then( ...
check
identifier_name
main.rs
extern crate ffmpeg_next as ffmpeg; extern crate pretty_env_logger; use std::env; use std::process::Command; use std::thread; use std::time; use futures::{FutureExt, StreamExt}; use http::Uri; use warp::Filter; use getopts::Options; //ffmpeg -i rtsp://192.xxx.xxx:5554 -y c:a aac -b:a 160000 -ac 2 s 854x480 -c:v libx...
"c:a", "aac", "-b:a", "160000", "-ac", "2", "s", "854x480", "-c:v", "libx264", "-b:v", "800000", "-hls_time", "10", "-hls_list_size", ...
format!("{}", input_address).as_str(), "-y",
random_line_split
main.rs
extern crate ffmpeg_next as ffmpeg; extern crate pretty_env_logger; use std::env; use std::process::Command; use std::thread; use std::time; use futures::{FutureExt, StreamExt}; use http::Uri; use warp::Filter; use getopts::Options; //ffmpeg -i rtsp://192.xxx.xxx:5554 -y c:a aac -b:a 160000 -ac 2 s 854x480 -c:v libx...
fn main() { let args: Vec<String> = env::args().collect(); let program = args[0].clone(); let mut opts = Options::new(); opts.optopt("o", "", "set output file name", "NAME"); opts.optopt("i", "", "set input file name", "NAME"); opts.optflag("h", "help", "print this help menu"); let match...
{ let brief = format!("Usage: {} FILE [options]", program); print!("{}", opts.usage(&brief)); }
identifier_body
main.rs
extern crate ffmpeg_next as ffmpeg; extern crate pretty_env_logger; use std::env; use std::process::Command; use std::thread; use std::time; use futures::{FutureExt, StreamExt}; use http::Uri; use warp::Filter; use getopts::Options; //ffmpeg -i rtsp://192.xxx.xxx:5554 -y c:a aac -b:a 160000 -ac 2 s 854x480 -c:v libx...
(program: &str, opts: Options) { let brief = format!("Usage: {} FILE [options]", program); print!("{}", opts.usage(&brief)); } fn main() { let args: Vec<String> = env::args().collect(); let program = args[0].clone(); let mut opts = Options::new(); opts.optopt("o", "", "set output file name", "...
print_usage
identifier_name
main.rs
extern crate ffmpeg_next as ffmpeg; extern crate pretty_env_logger; use std::env; use std::process::Command; use std::thread; use std::time; use futures::{FutureExt, StreamExt}; use http::Uri; use warp::Filter; use getopts::Options; //ffmpeg -i rtsp://192.xxx.xxx:5554 -y c:a aac -b:a 160000 -ac 2 s 854x480 -c:v libx...
}; if matches.opt_present("h") { print_usage(&program, opts); return; } if!matches.opt_str("o").is_some() ||!matches.opt_str("i").is_some() { print_usage(&program, opts); return; } let input = matches.opt_str("i").expect("Expected input file"); let output =...
{ panic!(f.to_string()) }
conditional_block
upload_latest.rs
use crate::{api_client::{self, Client}, common::ui::{Status, UIWriter, UI}, error::{Error, Result}, PRODUCT, VERSION}; use habitat_core::{crypto::keys::{Key, ...
{ Ok(()) => ui.status(Status::Uploaded, public_key.named_revision())?, Err(api_client::Error::APIError(StatusCode::CONFLICT, _)) => { ui.status(Status::Using, format!("public key revision {} which already exists in the depot", public_ke...
{ let api_client = Client::new(bldr_url, PRODUCT, VERSION, None)?; ui.begin(format!("Uploading latest public origin key {}", &origin))?; // Figure out the latest public key let public_key: PublicOriginSigningKey = key_cache.latest_public_origin_signing_key(origin)?; // The path to the key in the c...
identifier_body
upload_latest.rs
use crate::{api_client::{self, Client}, common::ui::{Status, UIWriter, UI}, error::{Error, Result}, PRODUCT, VERSION}; use habitat_core::{crypto::keys::{Key, ...
(ui: &mut UI, bldr_url: &str, token: &str, origin: &Origin, with_secret: bool, key_cache: &KeyCache) -> Result<()> { let api_client = Client::new(bldr_url, PRODUCT, VERSION, None)?; ui.begin(format!...
start
identifier_name
upload_latest.rs
use crate::{api_client::{self, Client}, common::ui::{Status, UIWriter, UI}, error::{Error, Result},
PRODUCT, VERSION}; use habitat_core::{crypto::keys::{Key, KeyCache, PublicOriginSigningKey, SecretOriginSigningKey}, origin::Origin}; use reqwest::StatusCode; pub async fn st...
random_line_split
mod.rs
pub mod buffers; pub mod cursor; pub mod position; pub mod movement; pub mod insert; use gfx::Screen; use config::Players; use px8::PX8Config; use px8::editor::State; use self::buffers::BufferManager; use self::cursor::Cursor; use px8::editor::text::buffers::TextBuffer; use px8::editor::text::buffers::SplitBuffer; u...
else { c }; let pos_char_x = 4 * (x - scroll_x) as i32; let pos_char_y = 8 * (y - scroll_y) as i32; //info!("OFF C {:?} X {:?} {:?}", c, pos_char_x, pos_char_y); screen.print_char(c, pos_char_x, ...
{ ' ' }
conditional_block
mod.rs
pub mod buffers; pub mod cursor; pub mod position; pub mod movement; pub mod insert; use gfx::Screen; use config::Players; use px8::PX8Config; use px8::editor::State; use self::buffers::BufferManager; use self::cursor::Cursor; use px8::editor::text::buffers::TextBuffer; use px8::editor::text::buffers::SplitBuffer; u...
let y = self.cursor().y; self.buffers.current_buffer_mut().focus_hint_y(y); self.buffers.current_buffer_mut().focus_hint_x(x); } pub fn draw(&mut self, players: Arc<Mutex<Players>>, screen: &mut Screen) { let (scroll_x, scroll_y) = { let current_buffer = self.buffer...
let x = self.cursor().x;
random_line_split
mod.rs
pub mod buffers; pub mod cursor; pub mod position; pub mod movement; pub mod insert; use gfx::Screen; use config::Players; use px8::PX8Config; use px8::editor::State; use self::buffers::BufferManager; use self::cursor::Cursor; use px8::editor::text::buffers::TextBuffer; use px8::editor::text::buffers::SplitBuffer; u...
(&mut self, config: Arc<Mutex<PX8Config>>, screen: &mut Screen, filename: String, code: String) { info!("[GFX_EDITOR] Init"); info!("[GFX_EDITOR] {:?}", self.pos()); let mut new_buffer: Buffer = SplitBuffer::from_str(&code).into(); new_buffer.title = Some(filename); let new_bu...
init
identifier_name
macros.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 ...
/// Asserts that two expressions are equal to each other, testing equality in /// both directions. /// /// On panic, this macro will print the values of the expressions. /// /// # Example /// /// ``` /// let a = 3i; /// let b = 1i + 2i; /// assert_eq!(a, b); /// ``` #[macro_export] macro_rules! assert_eq( ($given:...
)
random_line_split
issue-3753.rs
// run-pass // Issue #3656 // Issue Name: pub method preceded by attribute can't be parsed // Abstract: Visibility parsing failed when compiler parsing use std::f64; #[derive(Copy, Clone)] pub struct Point { x: f64, y: f64 } #[derive(Copy, Clone)] pub enum
{ Circle(Point, f64), Rectangle(Point, Point) } impl Shape { pub fn area(&self, sh: Shape) -> f64 { match sh { Shape::Circle(_, size) => f64::consts::PI * size * size, Shape::Rectangle(Point {x, y}, Point {x: x2, y: y2}) => (x2 - x) * (y2 - y) } } } pub fn main...
Shape
identifier_name
issue-3753.rs
// run-pass // Issue #3656 // Issue Name: pub method preceded by attribute can't be parsed // Abstract: Visibility parsing failed when compiler parsing use std::f64; #[derive(Copy, Clone)]
pub struct Point { x: f64, y: f64 } #[derive(Copy, Clone)] pub enum Shape { Circle(Point, f64), Rectangle(Point, Point) } impl Shape { pub fn area(&self, sh: Shape) -> f64 { match sh { Shape::Circle(_, size) => f64::consts::PI * size * size, Shape::Rectangle(Point {...
random_line_split
rustbox.rs
extern crate gag; extern crate libc; extern crate num; extern crate time; extern crate termbox_sys as termbox; #[macro_use] extern crate bitflags; pub use self::style::{Style, RB_BOLD, RB_UNDERLINE, RB_REVERSE, RB_NORMAL}; use std::error::Error; use std::fmt; use std::io; use std::char; use std::default::Default; use...
pub fn set_cursor(&self, x: isize, y: isize) { unsafe { termbox::tb_set_cursor(x as c_int, y as c_int) } } pub unsafe fn change_cell(&self, x: usize, y: usize, ch: u32, fg: u16, bg: u16) { termbox::tb_change_cell(x as c_int, y as c_int, ch, fg, bg) } pub fn print(&self, x: usize,...
{ unsafe { termbox::tb_present() } }
identifier_body
rustbox.rs
extern crate gag; extern crate libc; extern crate num; extern crate time; extern crate termbox_sys as termbox; #[macro_use] extern crate bitflags; pub use self::style::{Style, RB_BOLD, RB_UNDERLINE, RB_REVERSE, RB_NORMAL}; use std::error::Error; use std::fmt; use std::io; use std::char; use std::default::Default; use...
(&mut self) { // Since only one instance of the RustBox is ever accessible, we should not // need to do this atomically. // Note: we should definitely have RUSTBOX_RUNNING = true here. unsafe { termbox::tb_shutdown(); } } }
drop
identifier_name
rustbox.rs
extern crate gag; extern crate libc; extern crate num; extern crate time; extern crate termbox_sys as termbox; #[macro_use] extern crate bitflags; pub use self::style::{Style, RB_BOLD, RB_UNDERLINE, RB_REVERSE, RB_NORMAL}; use std::error::Error; use std::fmt; use std::io; use std::char; use std::default::Default; use...
impl Error for InitError { fn description(&self) -> &str { match *self { InitError::BufferStderrFailed(_) => "Could not redirect stderr", InitError::AlreadyOpen => "RustBox is already open", InitError::UnsupportedTerminal => "Unsupported terminal", InitError::...
}
random_line_split
color.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use azure::AzFloat; use azure::azure_hl::Color as AzColor;
r: (r as AzFloat) / (255.0 as AzFloat), g: (g as AzFloat) / (255.0 as AzFloat), b: (b as AzFloat) / (255.0 as AzFloat), a: 1.0 as AzFloat } } #[inline] pub fn rgba(r: AzFloat, g: AzFloat, b: AzFloat, a: AzFloat) -> AzColor { AzColor { r: r, g: g, b: b, a: a } }
pub type Color = AzColor; #[inline] pub fn rgb(r: u8, g: u8, b: u8) -> AzColor { AzColor {
random_line_split
color.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use azure::AzFloat; use azure::azure_hl::Color as AzColor; pub type Color = AzColor; #[inline] pub fn rgb(r: u8,...
#[inline] pub fn rgba(r: AzFloat, g: AzFloat, b: AzFloat, a: AzFloat) -> AzColor { AzColor { r: r, g: g, b: b, a: a } }
{ AzColor { r: (r as AzFloat) / (255.0 as AzFloat), g: (g as AzFloat) / (255.0 as AzFloat), b: (b as AzFloat) / (255.0 as AzFloat), a: 1.0 as AzFloat } }
identifier_body
color.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use azure::AzFloat; use azure::azure_hl::Color as AzColor; pub type Color = AzColor; #[inline] pub fn rgb(r: u8,...
(r: AzFloat, g: AzFloat, b: AzFloat, a: AzFloat) -> AzColor { AzColor { r: r, g: g, b: b, a: a } }
rgba
identifier_name
export-glob-imports-target.rs
// xfail-fast // 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 // <...
use foo::bar::*; pub mod bar { pub static a : int = 10; } pub fn zum() { let _b = a; } } pub fn main() { }
mod foo {
random_line_split
export-glob-imports-target.rs
// xfail-fast // 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 // <...
{ }
identifier_body
export-glob-imports-target.rs
// xfail-fast // 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 // <...
() { }
main
identifier_name
mod.rs
use std::ops::{Deref, DerefMut}; use std::io::Read; use rocket::outcome::Outcome; use rocket::request::Request; use rocket::data::{self, Data, FromData}; use rocket::response::{self, Responder, content}; use rocket::http::Status; use serde::{Serialize, Deserialize}; use serde_json; pub use serde_json::Value; pub us...
/// # use rocket_contrib::JSON; /// let string = "Hello".to_string(); /// let my_json = JSON(string); /// assert_eq!(my_json.into_inner(), "Hello".to_string()); /// ``` pub fn into_inner(self) -> T { self.0 } } /// Maximum size of JSON is 1MB. /// TODO: Determine this size from some...
/// ```rust
random_line_split
mod.rs
use std::ops::{Deref, DerefMut}; use std::io::Read; use rocket::outcome::Outcome; use rocket::request::Request; use rocket::data::{self, Data, FromData}; use rocket::response::{self, Responder, content}; use rocket::http::Status; use serde::{Serialize, Deserialize}; use serde_json; pub use serde_json::Value; pub us...
} /// Maximum size of JSON is 1MB. /// TODO: Determine this size from some configuration parameter. const MAX_SIZE: u64 = 1048576; impl<T: Deserialize> FromData for JSON<T> { type Error = SerdeError; fn from_data(request: &Request, data: Data) -> data::Outcome<Self, SerdeError> { if!request.content_...
{ self.0 }
identifier_body
mod.rs
use std::ops::{Deref, DerefMut}; use std::io::Read; use rocket::outcome::Outcome; use rocket::request::Request; use rocket::data::{self, Data, FromData}; use rocket::response::{self, Responder, content}; use rocket::http::Status; use serde::{Serialize, Deserialize}; use serde_json; pub use serde_json::Value; pub us...
(self) -> T { self.0 } } /// Maximum size of JSON is 1MB. /// TODO: Determine this size from some configuration parameter. const MAX_SIZE: u64 = 1048576; impl<T: Deserialize> FromData for JSON<T> { type Error = SerdeError; fn from_data(request: &Request, data: Data) -> data::Outcome<Self, SerdeEr...
into_inner
identifier_name
archive_ro.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...
else { Some(slice::from_raw_parts(ptr as *const u8, size as usize)) } } } } impl Drop for ArchiveRO { fn drop(&mut self) { unsafe { ::LLVMRustDestroyArchive(self.ptr); } } }
{ None }
conditional_block
archive_ro.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...
} /// Reads a file in the archive pub fn read<'a>(&'a self, file: &str) -> Option<&'a [u8]> { unsafe { let mut size = 0 as libc::size_t; let file = CString::new(file).unwrap(); let ptr = ::LLVMRustArchiveReadSection(self.ptr, file.as_ptr(), ...
#[cfg(windows)] fn path2cstr(p: &Path) -> CString { CString::new(p.to_str().unwrap()).unwrap() }
random_line_split
archive_ro.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...
(p: &Path) -> CString { CString::new(p.to_str().unwrap()).unwrap() } } /// Reads a file in the archive pub fn read<'a>(&'a self, file: &str) -> Option<&'a [u8]> { unsafe { let mut size = 0 as libc::size_t; let file = CString::new(file).unwrap(); ...
path2cstr
identifier_name
archive_ro.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...
} /// Reads a file in the archive pub fn read<'a>(&'a self, file: &str) -> Option<&'a [u8]> { unsafe { let mut size = 0 as libc::size_t; let file = CString::new(file).unwrap(); let ptr = ::LLVMRustArchiveReadSection(self.ptr, file.as_ptr(), ...
{ CString::new(p.to_str().unwrap()).unwrap() }
identifier_body
plane.rs
// +--------------------------------------------------------------------------+ // | Copyright 2016 Matthew D. Steele <mdsteele@alum.mit.edu> | // | | // | This file is part of System Syzygy. | ...
( &self, grid: &PlaneGrid, pos: Point, dir: Direction, canvas: &mut Canvas, ) { let obj = grid.objects().get(&pos).cloned(); let sprite_index = match (dir, obj) { (Direction::West, Some(PlaneObj::Cross)) => 10, (Direction::West, Some(ob...
draw_pipe_tip
identifier_name
plane.rs
// +--------------------------------------------------------------------------+ // | Copyright 2016 Matthew D. Steele <mdsteele@alum.mit.edu> | // | | // | This file is part of System Syzygy. | ...
} (Direction::North, Direction::East) => 4, (Direction::North, Direction::West) => 7, (Direction::South, Direction::East) => 5, (Direction::South, Direction::West) => 6, (Direction::North, _) | (Dire...
{ 8 }
conditional_block
plane.rs
// +--------------------------------------------------------------------------+ // | Copyright 2016 Matthew D. Steele <mdsteele@alum.mit.edu> | // | | // | This file is part of System Syzygy. | ...
pub fn cancel_drag_and_clear_changes(&mut self) { self.drag_from = None; self.changes.clear(); } pub fn cancel_drag_and_undo_changes(&mut self, grid: &mut PlaneGrid) { self.drag_from = None; for &(coords1, coords2) in self.changes.iter().rev() { grid.toggle_pip...
{ PlaneGridView { left, top, obj_sprites: resources.get_sprites("plane/objects"), pipe_sprites: resources.get_sprites("plane/pipes"), drag_from: None, changes: Vec::new(), font: resources.get_font("roman"), letters: ...
identifier_body
plane.rs
// +--------------------------------------------------------------------------+ // | Copyright 2016 Matthew D. Steele <mdsteele@alum.mit.edu> | // | | // | This file is part of System Syzygy. | ...
(Direction::North, Direction::West) => 7, (Direction::South, Direction::East) => 5, (Direction::South, Direction::West) => 6, (Direction::North, _) | (Direction::South, _) => 9, }; let sprite = &self.pipe_spr...
random_line_split
lib.rs
// Copyright 2015-2017 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 lat...
(&self, row: &Row, col: &Col) -> Option<&Val> { self.map.get(row).and_then(|r| r.get(col)) } /// Remove value from specific cell /// /// It will remove the row if it's the last value in it pub fn remove(&mut self, row: &Row, col: &Col) -> Option<Val> { let (val, is_empty) = { let row_map = self.map.get_mut...
get
identifier_name
lib.rs
// Copyright 2015-2017 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 lat...
/// Get immutable reference for single row in this Table pub fn row(&self, row: &Row) -> Option<&HashMap<Col, Val>> { self.map.get(row) } /// Get element in cell described by `(row, col)` pub fn get(&self, row: &Row, col: &Col) -> Option<&Val> { self.map.get(row).and_then(|r| r.get(col)) } /// Remove val...
{ self.map.contains_key(row) }
identifier_body
lib.rs
// Copyright 2015-2017 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 lat...
// then assert!(!table.has_row(&1)); assert_eq!(table.len(), 1); } }
table.clear_if_empty(&1);
random_line_split
lib.rs
// Copyright 2015-2017 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 lat...
val } /// Remove given row from Table if there are no values defined in it /// /// When using `#row_mut` it may happen that all values from some row are drained. /// Table however will not be aware that row is empty. /// You can use this method to explicitly remove row entry from the Table. pub fn clear_if_e...
{ self.map.remove(row); }
conditional_block
paged_results.rs
use super::{ControlParser, MakeCritical, RawControl}; use bytes::BytesMut; use lber::common::TagClass; use lber::IResult; use lber::parse::{parse_uint, parse_tag}; use lber::structures::{ASNTag, Integer, OctetString, Sequence, Tag}; use lber::universal::Types; use lber::write; /// Paged Results control ([RFC 2696](h...
val: Some(Vec::from(&buf[..])), } } } impl ControlParser for PagedResults { fn parse(val: &[u8]) -> PagedResults { let mut pr_comps = match parse_tag(val) { IResult::Done(_, tag) => tag, _ => panic!("failed to parse paged results value components"), ...
{ let cookie_len = pr.cookie.len(); let cval = Tag::Sequence(Sequence { inner: vec![ Tag::Integer(Integer { inner: pr.size as i64, .. Default::default() }), Tag::OctetString(OctetString { ...
identifier_body
paged_results.rs
use super::{ControlParser, MakeCritical, RawControl}; use bytes::BytesMut; use lber::common::TagClass; use lber::IResult; use lber::parse::{parse_uint, parse_tag}; use lber::structures::{ASNTag, Integer, OctetString, Sequence, Tag}; use lber::universal::Types; use lber::write; /// Paged Results control ([RFC 2696](h...
impl From<PagedResults> for RawControl { fn from(pr: PagedResults) -> RawControl { let cookie_len = pr.cookie.len(); let cval = Tag::Sequence(Sequence { inner: vec![ Tag::Integer(Integer { inner: pr.size as i64, .. Default::default()...
impl MakeCritical for PagedResults { }
random_line_split
paged_results.rs
use super::{ControlParser, MakeCritical, RawControl}; use bytes::BytesMut; use lber::common::TagClass; use lber::IResult; use lber::parse::{parse_uint, parse_tag}; use lber::structures::{ASNTag, Integer, OctetString, Sequence, Tag}; use lber::universal::Types; use lber::write; /// Paged Results control ([RFC 2696](h...
{ /// For requests, desired page size. For responses, a server's estimate /// of the result set size, if non-zero. pub size: i32, /// Paging cookie. pub cookie: Vec<u8>, } pub const PAGED_RESULTS_OID: &'static str = "1.2.840.113556.1.4.319"; impl MakeCritical for PagedResults { } impl From<Paged...
PagedResults
identifier_name
history.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. */ use abomonation_derive::Abomonation; use anyhow::Error; use filenodes::{FilenodeInfo, FilenodeInfoCached}; #[derive(Abomonation, Clone)] ...
let history = filenodes.into_iter().map(|f| f.into()).collect::<Vec<_>>(); Self { history } } }
pub fn from_filenodes(filenodes: Vec<FilenodeInfo>) -> Self {
random_line_split
history.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. */ use abomonation_derive::Abomonation; use anyhow::Error; use filenodes::{FilenodeInfo, FilenodeInfoCached}; #[derive(Abomonation, Clone)] ...
(self) -> Result<Vec<FilenodeInfo>, Error> { self.history.into_iter().map(|c| c.try_into()).collect() } pub fn from_filenodes(filenodes: Vec<FilenodeInfo>) -> Self { let history = filenodes.into_iter().map(|f| f.into()).collect::<Vec<_>>(); Self { history } } }
into_filenode_info
identifier_name
read_all.rs
use std::borrow::Cow; use std::convert::TryInto; use raw::client_messages; use raw::client_messages::mod_ReadAllEventsCompleted::ReadAllResult; use LogPosition; /// Successful response to `Message::ReadAllEvents`. #[derive(Debug, Clone, PartialEq)] pub struct ReadAllCompleted<'a> { /// Position of the commit of t...
impl<'a> From<client_messages::ResolvedEvent<'a>> for ResolvedEvent<'a> { fn from(e: client_messages::ResolvedEvent<'a>) -> ResolvedEvent<'a> { ResolvedEvent { event: e.event.into(), link: e.link.into(), commit_position: e.commit_position.try_into().unwrap(), ...
/// Position where this event is stored pub prepare_position: LogPosition, }
random_line_split
read_all.rs
use std::borrow::Cow; use std::convert::TryInto; use raw::client_messages; use raw::client_messages::mod_ReadAllEventsCompleted::ReadAllResult; use LogPosition; /// Successful response to `Message::ReadAllEvents`. #[derive(Debug, Clone, PartialEq)] pub struct ReadAllCompleted<'a> { /// Position of the commit of t...
<'a> { /// Unknown when this happens, NotModified, /// Other error Error(Option<Cow<'a, str>>), /// Access was denied (no credentials provided or insufficient permissions) AccessDenied } impl<'a> From<(ReadAllResult, Option<Cow<'a, str>>)> for ReadAllError<'a> { fn from((r, msg): (ReadAllRe...
ReadAllError
identifier_name
tex2.rs
use std::io::{self, Write}; use image; use image::GenericImage; use nom::{le_u8, le_u32}; use byteorder::{LittleEndian, WriteBytesExt}; named!(pub tex2_header<(u32, u32, u8)>, do_parse!( tag!("\x11\x40") >> //.@, the magic number for the format height: le_u32 >> width: le_u32 >> m...
(&self, x: u32, y: u32) -> usize { (calc_offset(self.height, self.width, (self.mipmap_current) as u32) + ((self.cur_width()*y) + x)) as usize } pub fn pixel(&self, x: u32, y: u32) -> (u8, u8, u8, u8) { match self.pixels.get(self.pos(x, y)) { Some(p) => *p, Non...
pos
identifier_name
tex2.rs
use std::io::{self, Write}; use image; use image::GenericImage; use nom::{le_u8, le_u32}; use byteorder::{LittleEndian, WriteBytesExt}; named!(pub tex2_header<(u32, u32, u8)>, do_parse!( tag!("\x11\x40") >> //.@, the magic number for the format height: le_u32 >> width: le_u32 >> m...
fn blend_pixel(&mut self, x: u32, y: u32, pixel: Self::Pixel) { unimplemented!() } } //12:36:48 AM <ubsan> zekesonxx: lemme think about it //12:36:51 AM <ubsan> I have an idea //12:37:24 AM <zekesonxx> ubsan: shoot //12:37:42 AM <ubsan> zekesonxx: alright, so the function definition would be somethi...
{ let pos = self.pos(x, y); self.pixels[pos] = (pixel[0], pixel[1], pixel[2], pixel[3]); }
identifier_body
tex2.rs
use std::io::{self, Write}; use image; use image::GenericImage; use nom::{le_u8, le_u32}; use byteorder::{LittleEndian, WriteBytesExt}; named!(pub tex2_header<(u32, u32, u8)>, do_parse!( tag!("\x11\x40") >> //.@, the magic number for the format height: le_u32 >> width: le_u32 >> mi...
} fn get_pixel(&self, x: u32, y: u32) -> Self::Pixel { let p = self.pixel(x, y); image::Rgba([p.0, p.1, p.2, p.3]) } fn get_pixel_mut(&mut self, x: u32, y: u32) -> &mut Self::Pixel { unimplemented!() } fn put_pixel(&mut self, x: u32, y: u32, pixel: Self::Pixel) { ...
(self.cur_width(), self.cur_height()) } fn bounds(&self) -> (u32, u32, u32, u32) { (0, 0, self.cur_width(), self.cur_height())
random_line_split
messageevent.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::EventBinding::EventMethods; use dom::bindings::codegen::Bindings::MessageEve...
false, false, message, DOMString::new(), DOMString::new()); messageevent.upcast::<Event>().fire(target); } } impl MessageEventMethods for MessageEvent { #[allow(unsafe_code)] // https://html.spec.whatwg.org/multipage/#dom-messageevent-data...
atom!("message"),
random_line_split
messageevent.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::EventBinding::EventMethods; use dom::bindings::codegen::Bindings::MessageEve...
(global: &GlobalScope, data: HandleValue, origin: DOMString, lastEventId: DOMString) -> Root<MessageEvent> { let ev = box MessageEvent { event: Event::new_inherited(), data: Heap::new(data.get()), ...
new_initialized
identifier_name
messageevent.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::EventBinding::EventMethods; use dom::bindings::codegen::Bindings::MessageEve...
// https://dom.spec.whatwg.org/#dom-event-istrusted fn IsTrusted(&self) -> bool { self.event.IsTrusted() } }
{ self.lastEventId.clone() }
identifier_body
buffer.rs
use crate::parsing::ParsingContext; use amq_protocol::frame::{BackToTheBuffer, GenError, GenResult, WriteContext}; use futures_lite::io::{AsyncRead, AsyncWrite}; use std::{ cmp, io::{self, IoSlice, IoSliceMut}, pin::Pin, task::{Context, Poll}, }; #[derive(Debug, PartialEq, Clone)] pub(crate) struct Buf...
; self.fill(amt); Ok(amt) } fn flush(&mut self) -> io::Result<()> { Ok(()) } } impl BackToTheBuffer for &mut Buffer { fn reserve_write_use< Tmp, Gen: Fn(WriteContext<Self>) -> Result<(WriteContext<Self>, Tmp), GenError>, Before: Fn(WriteContext<Self>, Tm...
{ let mut space = &mut self.memory[self.end..self.position]; space.write(data)? }
conditional_block
buffer.rs
use crate::parsing::ParsingContext; use amq_protocol::frame::{BackToTheBuffer, GenError, GenResult, WriteContext}; use futures_lite::io::{AsyncRead, AsyncWrite}; use std::{ cmp, io::{self, IoSlice, IoSliceMut}, pin::Pin, task::{Context, Poll}, }; #[derive(Debug, PartialEq, Clone)] pub(crate) struct Buf...
fn reserve_write_use< Tmp, Gen: Fn(WriteContext<Self>) -> Result<(WriteContext<Self>, Tmp), GenError>, Before: Fn(WriteContext<Self>, Tmp) -> GenResult<Self>, >( s: WriteContext<Self>, reserved: usize, gen: &Gen, before: &Before, ) -> Result<WriteConte...
} } impl BackToTheBuffer for &mut Buffer {
random_line_split
buffer.rs
use crate::parsing::ParsingContext; use amq_protocol::frame::{BackToTheBuffer, GenError, GenResult, WriteContext}; use futures_lite::io::{AsyncRead, AsyncWrite}; use std::{ cmp, io::{self, IoSlice, IoSliceMut}, pin::Pin, task::{Context, Poll}, }; #[derive(Debug, PartialEq, Clone)] pub(crate) struct Buf...
(&mut self, new_size: usize) -> bool { if self.capacity >= new_size { return false; } let old_capacity = self.capacity; let growth = new_size - old_capacity; self.memory.resize(new_size, 0); self.capacity = new_size; if self.end <= self.position && ...
grow
identifier_name
buffer.rs
use crate::parsing::ParsingContext; use amq_protocol::frame::{BackToTheBuffer, GenError, GenResult, WriteContext}; use futures_lite::io::{AsyncRead, AsyncWrite}; use std::{ cmp, io::{self, IoSlice, IoSliceMut}, pin::Pin, task::{Context, Poll}, }; #[derive(Debug, PartialEq, Clone)] pub(crate) struct Buf...
pub(crate) fn poll_write_to<T: AsyncWrite>( &self, cx: &mut Context<'_>, writer: Pin<&mut T>, ) -> Poll<io::Result<usize>> { if self.available_data() == 0 { Poll::Ready(Ok(0)) } else if self.end > self.position { writer.poll_write(cx, &self.memor...
{ let cnt = cmp::min(count, self.available_space()); self.end += cnt; self.end %= self.capacity; self.available_data += cnt; cnt }
identifier_body
scalar.rs
use std::cmp; use std::fmt; use std::ops; use num; use math::common::LinearInterpolate; pub type IntScalar = i32; #[cfg(not(feature = "float64"))] pub type FloatScalar = f32; #[cfg(feature = "float64")] pub type FloatScalar = f64; pub trait BaseNum where Self: Copy + Clone + fmt::Debug + cmp::PartialOrd, Sel...
pub fn partial_max<T: cmp::PartialOrd>(a: T, b: T) -> T { if a > b { a } else { b } } impl LinearInterpolate for f32 { type Scalar = f32; } impl LinearInterpolate for f64 { type Scalar = f64; }
{ if a < b { a } else { b } }
identifier_body
scalar.rs
use std::cmp; use std::fmt; use std::ops; use num; use math::common::LinearInterpolate; pub type IntScalar = i32; #[cfg(not(feature = "float64"))] pub type FloatScalar = f32; #[cfg(feature = "float64")] pub type FloatScalar = f64; pub trait BaseNum where Self: Copy + Clone + fmt::Debug + cmp::PartialOrd, Sel...
if a > b { a } else { b } } impl LinearInterpolate for f32 { type Scalar = f32; } impl LinearInterpolate for f64 { type Scalar = f64; }
pub fn partial_max<T: cmp::PartialOrd>(a: T, b: T) -> T {
random_line_split
scalar.rs
use std::cmp; use std::fmt; use std::ops; use num; use math::common::LinearInterpolate; pub type IntScalar = i32; #[cfg(not(feature = "float64"))] pub type FloatScalar = f32; #[cfg(feature = "float64")] pub type FloatScalar = f64; pub trait BaseNum where Self: Copy + Clone + fmt::Debug + cmp::PartialOrd, Sel...
} pub fn partial_max<T: cmp::PartialOrd>(a: T, b: T) -> T { if a > b { a } else { b } } impl LinearInterpolate for f32 { type Scalar = f32; } impl LinearInterpolate for f64 { type Scalar = f64; }
{ b }
conditional_block
scalar.rs
use std::cmp; use std::fmt; use std::ops; use num; use math::common::LinearInterpolate; pub type IntScalar = i32; #[cfg(not(feature = "float64"))] pub type FloatScalar = f32; #[cfg(feature = "float64")] pub type FloatScalar = f64; pub trait BaseNum where Self: Copy + Clone + fmt::Debug + cmp::PartialOrd, Sel...
<T: cmp::PartialOrd>(a: T, b: T) -> T { if a < b { a } else { b } } pub fn partial_max<T: cmp::PartialOrd>(a: T, b: T) -> T { if a > b { a } else { b } } impl LinearInterpolate for f32 { type Scalar = f32; } impl LinearInterpolate for f64 { type Scalar ...
partial_min
identifier_name
main.rs
extern crate rand; use std::io; use std::cmp::Ordering; use rand::Rng; fn
() { println!("Guess the number!"); let secret_number = rand::thread_rng().gen_range(1, 101); //println!("The secret number is: {}", secret_number); loop { println!("Please input your guess."); let mut guess = String::new(); io::stdin().read_line(&mut guess) .expe...
main
identifier_name
main.rs
extern crate rand; use std::io; use std::cmp::Ordering; use rand::Rng; fn main() { println!("Guess the number!"); let secret_number = rand::thread_rng().gen_range(1, 101); //println!("The secret number is: {}", secret_number); loop { println!("Please input your guess."); let mut gu...
println!("You guessed: {}", guess); match guess.cmp(&secret_number) { Ordering::Less => println!("Too small!"), Ordering::Greater => println!("Too big!"), Ordering::Equal => { println!("You win!"); break; } } ...
};
random_line_split
main.rs
extern crate rand; use std::io; use std::cmp::Ordering; use rand::Rng; fn main()
println!("You guessed: {}", guess); match guess.cmp(&secret_number) { Ordering::Less => println!("Too small!"), Ordering::Greater => println!("Too big!"), Ordering::Equal => { println!("You win!"); break; } } ...
{ println!("Guess the number!"); let secret_number = rand::thread_rng().gen_range(1, 101); //println!("The secret number is: {}", secret_number); loop { println!("Please input your guess."); let mut guess = String::new(); io::stdin().read_line(&mut guess) .expect...
identifier_body
problem3.rs
/* Run tests with; * * rustc --test problem3.rs ;./problem3 * */ fn prime_factors(mut n: i64) -> Vec<i64> { let mut divisor = 2; let mut factors: Vec<i64> = Vec::new(); while divisor <= (n as f64).sqrt() as i64 { if n%divisor == 0
else { divisor += 1; } } factors.push(n); return factors; } pub fn main() { let factors = prime_factors(600851475143); let largest_prime_factor = factors.last().unwrap(); println!("largest prime factor == {}", largest_prime_factor); } #[cfg(test)] mod test { use super:...
{ factors.push(divisor); n = n / divisor; divisor = 2; }
conditional_block
problem3.rs
/* Run tests with; * * rustc --test problem3.rs ;./problem3 * */ fn prime_factors(mut n: i64) -> Vec<i64> { let mut divisor = 2;
n = n / divisor; divisor = 2; } else { divisor += 1; } } factors.push(n); return factors; } pub fn main() { let factors = prime_factors(600851475143); let largest_prime_factor = factors.last().unwrap(); println!("largest prime factor == {}", l...
let mut factors: Vec<i64> = Vec::new(); while divisor <= (n as f64).sqrt() as i64 { if n%divisor == 0 { factors.push(divisor);
random_line_split
problem3.rs
/* Run tests with; * * rustc --test problem3.rs ;./problem3 * */ fn prime_factors(mut n: i64) -> Vec<i64> { let mut divisor = 2; let mut factors: Vec<i64> = Vec::new(); while divisor <= (n as f64).sqrt() as i64 { if n%divisor == 0 { factors.push(divisor); n = n / divis...
#[cfg(test)] mod test { use super::prime_factors; #[test] fn correct_answer() { let factors = prime_factors(600851475143); let expected_answer = 6857; let computed_answer = *factors.last().unwrap(); assert_eq!(computed_answer, expected_answer); } }
{ let factors = prime_factors(600851475143); let largest_prime_factor = factors.last().unwrap(); println!("largest prime factor == {}", largest_prime_factor); }
identifier_body
problem3.rs
/* Run tests with; * * rustc --test problem3.rs ;./problem3 * */ fn prime_factors(mut n: i64) -> Vec<i64> { let mut divisor = 2; let mut factors: Vec<i64> = Vec::new(); while divisor <= (n as f64).sqrt() as i64 { if n%divisor == 0 { factors.push(divisor); n = n / divis...
() { let factors = prime_factors(600851475143); let largest_prime_factor = factors.last().unwrap(); println!("largest prime factor == {}", largest_prime_factor); } #[cfg(test)] mod test { use super::prime_factors; #[test] fn correct_answer() { let factors = prime_factors(600851475143);...
main
identifier_name
issue-52742.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
impl Foo<'_, '_> { fn take_bar(&mut self, b: Bar<'_>) { self.y = b.z //~^ ERROR unsatisfied lifetime constraints } } fn main() { }
z: &'b u32 }
random_line_split
issue-52742.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> { x: &'a u32, y: &'b u32, } struct Bar<'b> { z: &'b u32 } impl Foo<'_, '_> { fn take_bar(&mut self, b: Bar<'_>) { self.y = b.z //~^ ERROR unsatisfied lifetime constraints } } fn main() { }
Foo
identifier_name
issue-52742.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 main() { }
{ self.y = b.z //~^ ERROR unsatisfied lifetime constraints }
identifier_body
loader.rs
One of the immediate problems with linking the same library together twice //! in the same problem is dealing with duplicate symbols. The primary way to //! deal with this in rustc is to add hashes to the end of each symbol. //! //! In order to force hashes to change between versions of a library, if //! desired, the ...
Some(t) => t, }; if triple.as_slice()!= self.triple { info!("Rejecting via crate triple: expected {} got {}", self.triple, triple); self.rejected_via_triple.push(CrateMismatch { path: libpath.clone(), got: triple.to_string() ...
{ debug!("triple not present"); return false }
conditional_block